public void Configure(IServiceCollection serviceCollection) { var automappedAssemblies = IgnitionAutomapHelper.GetAutomappedAssemblies(); foreach (var automappedAssembly in automappedAssemblies) { serviceCollection.AddMvcControllers(automappedAssembly); var configuratorTypes = GetServicesConfiguratorTypesFromAssembly(automappedAssembly); foreach (var configuratorType in configuratorTypes) { var configurator = (IServicesConfigurator)Activator.CreateInstance(configuratorType); configurator.Configure(serviceCollection); } } }
public override void Process(AddMapsPipelineArgs args) { var factory = new SitecoreSettingsFactory(); var automappedAssemblies = IgnitionAutomapHelper.GetAutomappedAssemblies(); var manyTypes = automappedAssemblies.SelectMany(s => s.GetTypes()); var filteredTypes = manyTypes.Where(p => typeof(IGlassMap).IsAssignableFrom(p) && !p.IsAbstract && !p.IsInterface).ToList(); filteredTypes.ForEach(a => args.MapsConfigFactory.Add(() => { var mapper = (IGlassMap)Activator.CreateInstance(a); var setting = mapper as IGlassSettingsConsumer; if (setting != null) { setting.SettingsFactory = factory; } return((IGlassMap)setting ?? mapper); })); }