Exemple #1
0
 /// <summary>
 /// 获取给定字段的值
 /// </summary>
 /// <param name="t"></param>
 /// <param name="filed"></param>
 public static object GetValue <T>(T Class, string filed) where T : class, new()
 {
     return(BaseHelper.GetPropertyInfo(typeof(T), filed).GetValue(Class, null));
 }
Exemple #2
0
 /// <summary>
 /// 设置给定字段的值
 /// </summary>
 /// <param name="t"></param>
 /// <param name="filed"></param>
 /// <param name="value"></param>
 public static void SetValue <T>(T Class, string filed, object value) where T : class, new()
 {
     BaseHelper.GetPropertyInfo(Class.GetType(), filed).SetValue(Class, value, null);
 }
Exemple #3
0
 /// <summary>
 /// 获取 属性 PropertyInfo 对象 【 发现属性 (Property) 的属性 (Attribute) 并提供对属性 (Property) 元数据的访问。】
 /// </summary>
 /// <param name="filed">字段</param>
 /// <returns></returns>
 public PropertyInfo GetPropertyInfo(T model, string filed)
 {
     return(BaseHelper.GetPropertyInfo(model.GetType(), filed));
 }
Exemple #4
0
        /// <summary>
        /// 获取自定字段的别名
        /// </summary>
        /// <param name="filed">字段</param>
        /// <returns></returns>
        public string GetDisplayName(T model, string filed)
        {
            var val = (BaseHelper.GetPropertyInfo(model.GetType(), filed).GetCustomAttribute(typeof(ObjectRemarks.FieldAttribute)) as ObjectRemarks.FieldAttribute);

            return(val == null ? string.Empty : val.Alias);
        }
Exemple #5
0
 /// <summary>
 /// 获取字段的自定标记 信息
 /// </summary>
 /// <typeparam name="BaseSign">返回标记</typeparam>
 /// <param name="filed">字段</param>
 /// <param name="bs">传入标记</param>
 /// <returns></returns>
 public BaseSign GetAttrTag <BaseSign>(T model, string filed) where BaseSign : Attribute
 {
     return((BaseHelper.GetPropertyInfo(model.GetType(), filed).GetCustomAttribute(typeof(BaseSign))) as BaseSign);
 }
Exemple #6
0
 /// <summary>
 /// 获取字段的标记的集合
 /// </summary>
 /// <param name="filed">字段</param>
 /// <returns></returns>
 public List <Attribute> GetAttrTag(T model, string filed)
 {
     return(BaseHelper.GetPropertyInfo(model.GetType(), filed).GetCustomAttributes().ToList());
 }