public IDictionary <string, IBackend> CreateAll() { var result = new Dictionary <string, IBackend>(); foreach (var component in ComponentProvider.GetAll()) { foreach (var type in component.Assembly.Types) { var attribute = type.GetCustomAttribute <DataTableBackendAttribute>(); if (attribute == null) { continue; } if (!typeof(IBackend).IsAssignableFrom(type)) { throw new DataTableBackendDoesNotImplementIBackendException(type); } result.Add(attribute.Id, (IBackend)Instantiator.Instantiate(type)); } } return(result); }
public IEnumerable <T> GetAll <T>() where T : IComposable { return(ComponentProvider .GetAll() .Select(c => c.Assembly) .SelectMany(a => a.Types) .Where(t => t.IsClass && !t.IsAbstract && !t.IsInterface && typeof(T).IsAssignableFrom(t)) .Select(t => (T)Instantiator.Instantiate(t)) .ToList() .AsReadOnly()); }
public IEnumerable <IDependencyInjector> Create() { var result = new List <IDependencyInjector>(); foreach (var component in ComponentProvider.GetAll()) { foreach (var type in component.Assembly.Types) { if (!typeof(IDependencyInjector).IsAssignableFrom(type)) { continue; } if (type.IsAbstract || type.IsInterface) { continue; } result.Add((IDependencyInjector)Instantiator.Instantiate(type)); } } return(result); }
public IEnumerable <UIHintControlMapping> Create() { var result = new List <UIHintControlMapping>(); foreach (var component in ComponentProvider.GetAll()) { foreach (var type in component.Assembly.Types) { var controlAttribute = type.GetCustomAttribute <ControlAttribute>(); if (controlAttribute == null) { continue; } foreach (var mapControlToUIHintAttribute in type.GetCustomAttributes <MapControlToUIHintAttribute>()) { result.Add(new UIHintControlMapping(UIHintDefinitionParser.Parse(mapControlToUIHintAttribute.UIHintDefinition), controlAttribute.Id)); } } } return(result.AsReadOnly()); }