45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace Appointment.Entity.Utility
|
|
{
|
|
/// <summary>
|
|
/// 正则表达式
|
|
/// </summary>
|
|
public static class RegexHelper
|
|
{
|
|
/// <summary>
|
|
/// 判断是否为手机号码
|
|
/// </summary>
|
|
/// <param name="value">字符串</param>
|
|
/// <returns>True-是,False-否</returns>
|
|
/// <remarks>
|
|
/// Add:yuangb 2016-6-12
|
|
/// </remarks>
|
|
public static bool IsPhone(this string value)
|
|
{
|
|
value = value.Replace("+86", "");
|
|
return Regex.IsMatch(value, @"^1[3-9]{1}[0-9]{9}$");
|
|
}
|
|
|
|
public static TChild AutoCopy<TParent, TChild>(TParent parent) where TChild : TParent, new()
|
|
{
|
|
TChild child = new TChild();
|
|
var ParentType = typeof(TParent);
|
|
var Properties = ParentType.GetProperties();
|
|
foreach (var Propertie in Properties)
|
|
{
|
|
//循环遍历属性
|
|
if (Propertie.CanRead && Propertie.CanWrite)
|
|
{
|
|
//进行属性拷贝
|
|
Propertie.SetValue(child, Propertie.GetValue(parent, null), null);
|
|
}
|
|
}
|
|
return child;
|
|
}
|
|
}
|
|
}
|