public IEnumerable <CoreInterfaceDescriptor> Create() { var result = new List <CoreInterfaceDescriptor>(); foreach (var type in ComponentProvider.GetAll().SelectMany(c => c.Assembly.Types)) { if (!type.IsInterface) { continue; } var coreInterfaceAttribute = type.GetCustomAttribute <CoreInterfaceAttribute>(); if (coreInterfaceAttribute == null) { continue; } var propertyDefinitions = new List <PropertyDefinitionDescriptor>(); foreach (var property in type.GetProperties()) { propertyDefinitions.Add(PropertyDefinitionCreator.Create(property)); } result.Add(new CoreInterfaceDescriptor(coreInterfaceAttribute.Id, type, propertyDefinitions)); } return(result.AsReadOnly()); }
public IEnumerable <ContentTypeDescriptor> Create() { var types = ComponentProvider .GetAll() .SelectMany(a => a.Assembly.Types) .Where(a => typeof(IContent).IsAssignableFrom(a)); var result = new List <ContentTypeDescriptor>(); foreach (var type in types) { var contentTypeAttribute = type.GetTypeInfo().GetCustomAttribute <ContentTypeAttribute>(); if (contentTypeAttribute == null) { continue; } var container = type.GetTypeInfo().GetCustomAttribute <ContainerAttribute>()?.Id ?? ContainerConstants.Content; var propertyDefinitions = new List <PropertyDefinitionDescriptor>(); foreach (var property in type.GetProperties()) { var mapping = PropertyMappingRepository.Get(property); if (mapping.PropertyMappingType == PropertyMappingType.Ignored) { continue; } if (mapping.PropertyMappingType == PropertyMappingType.CoreInterface) { continue; } if (mapping.PropertyMappingType == PropertyMappingType.Incomplete) { continue; } propertyDefinitions.Add(PropertyDefinitionCreator.Create(property)); } var coreInterfaces = type.GetInterfaces() .Select(i => CoreInterfaceProvider.GetFor(i)) .Where(i => i != null); result.Add(new ContentTypeDescriptor(contentTypeAttribute.Id, type, container, propertyDefinitions, coreInterfaces)); } return(result); }