本文整理匯總了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);
}
示例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);
}