コード例 #1
0
ファイル: FieldItem.cs プロジェクト: wuseyangg/X
        internal Field(TableItem table, String name, Type type, String description, Int32 length)
        {
            Table = table;

            Name        = name;
            ColumnName  = name;
            Type        = type;
            Description = description;
            Length      = length;

            IsNullable = true;
        }
コード例 #2
0
ファイル: FieldItem.cs プロジェクト: rebider/soa
        /// <summary>构造函数</summary>
        /// <param name="table"></param>
        /// <param name="property"></param>
        public FieldItem(TableItem table, PropertyInfo property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            _Table = table;

            _Property        = property;
            _Column          = BindColumnAttribute.GetCustomAttribute(_Property);
            _DataObjectField = DataObjectAttribute.GetCustomAttribute(_Property, typeof(DataObjectFieldAttribute)) as DataObjectFieldAttribute;
            _Description     = DescriptionAttribute.GetCustomAttribute(_Property, typeof(DescriptionAttribute)) as DescriptionAttribute;
        }
コード例 #3
0
ファイル: FieldItem.cs プロジェクト: Underwood12/csharp
        /// <summary>构造函数</summary>
        /// <param name="table"></param>
        /// <param name="property">属性</param>
        public FieldItem(TableItem table, PropertyInfo property)
        {
            Table = table;

            if (property != null)
            {
                _Property = property;
                var dc = _Column = BindColumnAttribute.GetCustomAttribute(property);
                var df = _DataObjectField = property.GetCustomAttribute<DataObjectFieldAttribute>();
                var ds = _Description = property.GetCustomAttribute<DescriptionAttribute>();
                var di = _DisplayName = property.GetCustomAttribute<DisplayNameAttribute>();
                Map = property.GetCustomAttribute<MapAttribute>();
                Name = property.Name;
                Type = property.PropertyType;
                DeclaringType = property.DeclaringType;

                if (df != null)
                {
                    IsIdentity = df.IsIdentity;
                    PrimaryKey = df.PrimaryKey;
                    IsNullable = df.IsNullable;
                    Length = df.Length;

                    IsDataObjectField = true;
                }

                if (dc != null)
                {
                    Master = dc.Master;
                }

                if (dc != null && !dc.Name.IsNullOrWhiteSpace())
                    ColumnName = dc.Name;
                else
                    ColumnName = Name;

                if (ds != null && !String.IsNullOrEmpty(ds.Description))
                    Description = ds.Description;
                else if (dc != null && !String.IsNullOrEmpty(dc.Description))
                    Description = dc.Description;
                if (di != null && !di.DisplayName.IsNullOrEmpty())
                    DisplayName = di.DisplayName;

                var map = Map;
                if (map == null || map.Provider == null) ReadOnly = !property.CanWrite;
                var ra = property.GetCustomAttribute<ReadOnlyAttribute>();
                if (ra != null) ReadOnly = ra.IsReadOnly;
            }
        }
コード例 #4
0
ファイル: FieldItem.cs プロジェクト: windygu/asxinyunet
 /// <summary>构造函数</summary>
 /// <param name="table"></param>
 /// <param name="property"></param>
 public Field(TableItem table, PropertyInfo property) : base(table, property) { }
コード例 #5
0
ファイル: FieldItem.cs プロジェクト: windygu/asxinyunet
        /// <summary>构造函数</summary>
        /// <param name="table"></param>
        /// <param name="property"></param>
        public FieldItem(TableItem table, PropertyInfo property)
        {
            if (property == null) throw new ArgumentNullException("property");

            _Table = table;

            _Property = property;
            _Column = BindColumnAttribute.GetCustomAttribute(_Property);
            _DataObjectField = DataObjectAttribute.GetCustomAttribute(_Property, typeof(DataObjectFieldAttribute)) as DataObjectFieldAttribute;
            _Description = DescriptionAttribute.GetCustomAttribute(_Property, typeof(DescriptionAttribute)) as DescriptionAttribute;
        }
コード例 #6
0
ファイル: FieldItem.cs プロジェクト: wuseyangg/X
 /// <summary>构造函数</summary>
 /// <param name="table"></param>
 /// <param name="property">属性</param>
 public Field(TableItem table, PropertyInfo property) : base(table, property)
 {
 }
コード例 #7
0
        /// <summary>构造函数</summary>
        /// <param name="table"></param>
        /// <param name="property">属性</param>
        public FieldItem(TableItem table, PropertyInfo property)
        {
            //if (property == null) throw new ArgumentNullException("property");

            _Table = table;

            if (property != null)
            {
                _Property = property;
                var dc = _Column = BindColumnAttribute.GetCustomAttribute(property);
                var df = _DataObjectField = property.GetCustomAttribute <DataObjectFieldAttribute>();
                var ds = _Description = property.GetCustomAttribute <DescriptionAttribute>();
                var di = _DisplayName = property.GetCustomAttribute <DisplayNameAttribute>();
                Name          = property.Name;
                Type          = property.PropertyType;
                DeclaringType = property.DeclaringType;

                if (df != null)
                {
                    IsIdentity = df.IsIdentity;
                    PrimaryKey = df.PrimaryKey;
                    IsNullable = df.IsNullable;
                    Length     = df.Length;

                    IsDataObjectField = true;
                }

                if (dc != null)
                {
                    _ID    = dc.Order;
                    Master = dc.Master;
                }

                if (dc != null && !dc.Name.IsNullOrWhiteSpace())
                {
                    ColumnName = dc.Name;
                }
                else
                {
                    ColumnName = Name;
                }

                if (ds != null && !String.IsNullOrEmpty(ds.Description))
                {
                    Description = ds.Description;
                }
                else if (dc != null && !String.IsNullOrEmpty(dc.Description))
                {
                    Description = dc.Description;
                }
                if (di != null && !di.DisplayName.IsNullOrEmpty())
                {
                    DisplayName = di.DisplayName;
                }

                _ReadOnly = !property.CanWrite;
                var ra = property.GetCustomAttribute <ReadOnlyAttribute>();
                if (ra != null)
                {
                    _ReadOnly = ra.IsReadOnly;
                }
            }
        }