Beispiel #1
0
        private static QueryColumn CreateFromAttribute(ActiveColumnAttribute attr, MemberInfo info, TableData parentTable)
        {
            ForeignColumnAttribute     foreignAttr  = Attribute.GetCustomAttribute(info, typeof(ForeignColumnAttribute)) as ForeignColumnAttribute;
            LocalizableColumnAttribute localizeAttr = Attribute.GetCustomAttribute(info, typeof(LocalizableColumnAttribute)) as LocalizableColumnAttribute;

            return(new TableColumnData(parentTable, attr.Name, attr.DbType, attr.MaxLength, attr.ColumnProperties, attr.DefaultValue, null,
                                       foreignAttr == null ? null : Create(foreignAttr), localizeAttr == null ? null : Create(localizeAttr)));
        }
Beispiel #2
0
 internal static IEnumerable <QueryColumn> CreateColumns(TableData parentTable, Type dataRecordType)
 {
     foreach (PropertyInfo property in dataRecordType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
     {
         ActiveColumnAttribute attribute = (ActiveColumnAttribute)Attribute.GetCustomAttribute(property, typeof(ActiveColumnAttribute));
         if (attribute != null)
         {
             yield return(CreateFromAttribute(attribute, property, parentTable));
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Creates a new <see cref="IQueryableColumn"/> from the supplied <paramref name="dataRecordType"/> and <paramref name="columnName"/>.
        /// </summary>
        /// <remarks>
        /// <para>
        /// This overload creates a column from the metadata contained in an <see cref="ActiveColumnAttribute"/>.
        /// The attribute should be applied to a member of the type represented by the <paramref name="dataRecordType"/> parameter.</para>
        /// <para>
        /// The <see cref="Type"/> specified by the <paramref name="dataRecordType"/> will be searched for an <see cref="ActiveColumnAttribute"/>
        /// that has a value in the <see cref="DynamicPropertyAttribute.Name"/> property matching the supplied <paramref name="columnName"/>.</para>
        /// </remarks>
        /// <param name="parentTable">An <see cref="TableData"/> implementation representing the table this column belongs to.</param>
        /// <param name="dataRecordType">A <see cref="Type"/> containing a member with an <see cref="ActiveColumnAttribute"/> applied to it.</param>
        /// <param name="columnName">The value specified in the <see cref="DynamicPropertyAttribute.Name"/> property of the <see cref="ActiveColumnAttribute"/>
        /// applied to the member.</param>
        /// <returns>A new <see cref="IQueryableColumn"/>.</returns>
        private static QueryColumn Create(TableData parentTable, Type dataRecordType, string columnName)
        {
            foreach (PropertyInfo property in dataRecordType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                ActiveColumnAttribute attribute = (ActiveColumnAttribute)Attribute.GetCustomAttribute(property, typeof(ActiveColumnAttribute));
                if (attribute == null || attribute.Name != columnName)
                {
                    continue;
                }

                return(CreateFromAttribute(attribute, property, parentTable));
            }

            return(null);
        }