/// <summary> /// 计算全部属性的MD5值 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="obj"></param> /// <returns></returns> public static string Md5 <T>(T obj) { string[] propertyNames = GetProperties(obj, null); Func <T, string> fun = CreateMd5Delegate(obj, propertyNames); return(fun == null ? "" : CryptographyHelper.MD5FromString(fun(obj))); }
/// <summary> /// 计算包含了displayAttribute特性的属性的MD5值 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="obj"></param> /// <param name="displayAttribute"></param> /// <returns></returns> public static string Md5 <T>(T obj, Type displayAttribute) { string[] propertyNames = GetProperties(obj, displayAttribute); Func <T, string> fun = CreateMd5Delegate(obj, propertyNames); string str = fun(obj); return(fun == null ? "" : CryptographyHelper.MD5FromString(str)); }