示例#1
0
 private static string Name(PropertyInfo property)
 {
     object[] attrs = property.GetCustomAttributes(typeof(ColumnModelAttribute), true);
     if (attrs.Length > 0)
     {
         ColumnModelAttribute att = attrs[0] as ColumnModelAttribute;
         if (att != null)
         {
             return(att.ColumName);
         }
     }
     return("");
 }
示例#2
0
 private static bool IsWriteable(PropertyInfo property)
 {
     object[] attributes = property.GetCustomAttributes(typeof(ColumnModelAttribute), false);
     if (attributes.Length == 1)
     {
         ColumnModelAttribute write = (ColumnModelAttribute)attributes[0];
         if (write != null)
         {
             return(true);
         }
     }
     return(false);
 }
示例#3
0
        /// <summary>
        ///  请求转换为对象(有特性)
        /// </summary>
        /// <param name="Model">实例对象</param>
        /// <param name="prop">属性</param>
        private static void RequestToModelHasAttributes(object Model, PropertyInfo prop)
        {
            ColumnModelAttribute dma = null;

            foreach (Attribute attr in Attribute.GetCustomAttributes(prop))
            {
                if (attr.GetType() == typeof(ColumnModelAttribute))
                {
                    dma = attr as ColumnModelAttribute;
                    object value = HttpContext.Current.Request[dma.DBColumnName];
                    SetRequestValue(Model, value, prop);
                }
            }
        }
示例#4
0
        /// <summary>
        ///  数据列转换为对象(有特性)
        /// </summary>
        /// <param name="Model">实例对象</param>
        /// <param name="dr">数据行</param>
        /// <param name="prop">属性</param>
        private static void DataRowToModelHasAttributes(object Model, DataRow dr, PropertyInfo prop)
        {
            ColumnModelAttribute dma = null;

            foreach (Attribute attr in Attribute.GetCustomAttributes(prop))
            {
                if (attr.GetType() == typeof(ColumnModelAttribute))
                {
                    dma = attr as ColumnModelAttribute;
                    if (!(dr[dma.DBColumnName] is DBNull))
                    {
                        prop.SetValue(Model, dr[dma.DBColumnName], null);
                    }
                    break;
                }
            }
        }