当前位置: 首页>>代码示例>>C#>>正文


C# Attribute.Union方法代码示例

本文整理汇总了C#中System.Attribute.Union方法的典型用法代码示例。如果您正苦于以下问题:C# Attribute.Union方法的具体用法?C# Attribute.Union怎么用?C# Attribute.Union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Attribute的用法示例。


在下文中一共展示了Attribute.Union方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateValueProperty

        /// <summary>
        /// Overridden to allow the addition of buddy-class attributes to the list of attributes associated with the <see cref="ModelType"/>
        /// </summary>
        /// <param name="declaringType"></param>
        /// <param name="property"></param>
        /// <param name="name"></param>
        /// <param name="isStatic"></param>
        /// <param name="isBoundary"></param>
        /// <param name="propertyType"></param>
        /// <param name="isList"></param>
        /// <param name="attributes"></param>
        /// <returns></returns>
        protected override ModelValueProperty CreateValueProperty(ModelType declaringType, System.Reflection.PropertyInfo property, string name, string label, string helptext, string format, bool isStatic, Type propertyType, TypeConverter converter, bool isList, bool isReadOnly, bool isPersisted, Attribute[] attributes)
        {
            // Do not include entity reference properties in the model
            if (property.PropertyType.IsSubclassOf(typeof(EntityReference)))
                return null;

            // Fetch any attributes associated with a buddy-class
            attributes = attributes.Union(GetBuddyClassAttributes(declaringType, property)).ToArray();

            // Mark properties that are not mapped as not persisted
            isPersisted = !attributes.OfType<NotMappedAttribute>().Any();

            return new EntityValueProperty(declaringType, property, name, label, helptext, format, isStatic, propertyType, converter, isList, isReadOnly, isPersisted, attributes);
        }
开发者ID:vc3,项目名称:ExoModel,代码行数:26,代码来源:EntityFrameworkTypeProvider.cs

示例2: CreateReferenceProperty

        /// <summary>
        /// Overridden to allow the addition of buddy-class attributes to the list of attributes associated with the <see cref="ModelType"/>
        /// </summary>
        /// <param name="declaringType"></param>
        /// <param name="property"></param>
        /// <param name="name"></param>
        /// <param name="isStatic"></param>
        /// <param name="isBoundary"></param>
        /// <param name="propertyType"></param>
        /// <param name="isList"></param>
        /// <param name="attributes"></param>
        /// <returns></returns>
        protected override ModelReferenceProperty CreateReferenceProperty(ModelType declaringType, System.Reflection.PropertyInfo property, string name, string label, string helptext, string format, bool isStatic, ModelType propertyType, bool isList, bool isReadOnly, bool isPersisted, Attribute[] attributes)
        {
            // Fetch any attributes associated with a buddy-class
            attributes = attributes.Union(GetBuddyClassAttributes(declaringType, property)).ToArray();

            // Mark properties that are not mapped as not persisted
            isPersisted = !attributes.OfType<NotMappedAttribute>().Any();

            // Determine whether the property represents an actual entity framework navigation property or an custom property
            var context = GetObjectContext();
            var type = context.ObjectContext.MetadataWorkspace.GetItem<EntityType>(((EntityModelType)declaringType).UnderlyingType.FullName, DataSpace.CSpace);
            NavigationProperty navProp;
            type.NavigationProperties.TryGetValue(name, false, out navProp);
            return new EntityReferenceProperty(declaringType, navProp, property, name, label, helptext, format, isStatic, propertyType, isList, isReadOnly, isPersisted, attributes);
        }
开发者ID:vc3,项目名称:ExoModel,代码行数:27,代码来源:EntityFrameworkTypeProvider.cs


注:本文中的System.Attribute.Union方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。