コード例 #1
0
        /// <summary> 实体解密(空值不解密)
        /// </summary>
        /// <typeparam name="T">实体类型</typeparam>
        /// <param name="t">实体</param>
        /// <returns>返回解密后的实体</returns>
        public static T DesModel <T>(T t)
        {
            T model = t;

            foreach (PropertyInfo item in t.GetType().GetProperties())
            {
                if (item.PropertyType.FullName == "System.String")
                {
                    object obj = item.GetValue(t, new object[] { });
                    if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
                    {
                        string value = obj.ToString();
                        value = Secret.Decrypt3DES_UTF8(value, GlobalStaticObj_YT.KeySecurity_YT);
                        item.SetValue(model, value, null);
                    }
                }
            }
            return(model);
        }