static IAttributesProvider GetExternalAndFluentAPIFilteringAttributesCore(Type componentType) { return(CompositeMetadataAttributesProvider.Create(new List <IAttributesProvider>() { GetExternalAndFluentAPIAttributesCore(componentType, false), GetExternalAndFluentAPIAttributesCore(componentType, true) })); }
public static IEnumerable <Attribute> GetExternalAndFluentAPIFilteringAttributes(Type componentType, string propertyName) { var attributesProvider = Providers.GetOrAdd(componentType, x => GetExternalAndFluentAPIAttributesCore(x)); var filteringAttributesProvider = FilteringProviders.GetOrAdd(componentType, x => GetExternalAndFluentAPIFilteringAttributesCore(x)); return(GetExternalAndFluentAPIAttributes(CompositeMetadataAttributesProvider.Create( new List <IAttributesProvider>() { attributesProvider, filteringAttributesProvider }), propertyName)); }
static IAttributesProvider GetExternalAndFluentAPIAttrbutesCore(Type componentType) { IEnumerable <IAttributesProvider> result = new IAttributesProvider[0]; foreach (var type in GetHierarchy(componentType)) { IEnumerable <Type> metadataClassType = DataAnnotationsAttributeHelper.GetMetadataClassType(type) .Return(x => new[] { x }, () => Enumerable.Empty <Type>()); IEnumerable <Type> externalMetadataClassTypes = GetMetadataTypes(MetadataLocator.Default, type); result = result.Concat(metadataClassType.Concat(externalMetadataClassTypes).GetProviders(type)); GetFluentAPIAttributesFromStaticMethod(type, type).Do(x => result = result.Concat(new[] { x })); } return(CompositeMetadataAttributesProvider.Create(result)); }
static IAttributesProvider GetExternalAndFluentAPIAttributesCore(Type componentType, bool forFiltering) { IEnumerable <Type> hierarchy = componentType.Yield().Flatten(x => x.BaseType.YieldIfNotNull()).Reverse(); IEnumerable <IAttributesProvider> result = new IAttributesProvider[0]; foreach (var type in hierarchy) { IEnumerable <Type> metadataClassType = (forFiltering ? GetFilteringMetadataClassType(type) : GetMetadataClassType(type)) .Return(x => new[] { x }, () => Enumerable.Empty <Type>()); IEnumerable <Type> externalMetadataClassTypes = GetMetadataTypes(MetadataLocator.Default, type); result = result.Concat(metadataClassType.Concat(externalMetadataClassTypes).GetProviders(type, forFiltering)); (forFiltering ? GetFluentAPIFilteringAttributesFromStaticMethod(type, type) : GetFluentAPIAttributesFromStaticMethod(type, type)) .Do(x => result = result.Concat(new[] { x })); } return(CompositeMetadataAttributesProvider.Create(result)); }
public static IAttributesProvider GetFilteringAttributesProvider(Type componentType, IMetadataLocator locator) { return(CompositeMetadataAttributesProvider.Create( GetMetadataTypes(locator, componentType).GetProviders(componentType, true))); }