using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Appointment.Entity.Utility
{
///
/// 正则表达式
///
public static class RegexHelper
{
///
/// 判断是否为手机号码
///
/// 字符串
/// True-是,False-否
///
/// Add:yuangb 2016-6-12
///
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 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;
}
}
}