protected virtual void AddServices(IServiceCollection services) { var typeFinder = new AppDomainTypeFinder(); typeFinder.FindClassesOfType(typeof(IDependency)) .Select(Activator.CreateInstance) .Cast <IDependency>().ToList() .ForEach(x => { x.Register(services); }); }
protected virtual void RunStartupTasks() { var typeFinder = new AppDomainTypeFinder(); typeFinder.FindClassesOfType <IStartupTask>() .Select(Activator.CreateInstance) .Cast <IStartupTask>() .OrderBy(x => x.Order).ToList() .ForEach(x => x.Execute()); }
protected virtual void RegisterMapperConfiguration() { //dependencies var typeFinder = new AppDomainTypeFinder(); //register mapper configurations provided by other assemblies var configurationActions = typeFinder.FindClassesOfType <IMapperConfiguration>() .Select(Activator.CreateInstance) .OfType <IMapperConfiguration>() .OrderBy(t => t.Order) .Select(t => t.GetConfiguration()) .ToList(); //register AutoMapperConfiguration.Init(configurationActions); }