public SillycoreApp Build() { foreach (Type type in AssemblyScanner.GetAllTypesOfInterface <IServiceConfigurator>()) { IServiceConfigurator configurator = (IServiceConfigurator)Activator.CreateInstance(type); configurator.Configure(Services, Configuration); } foreach (var task in _beforeBuildTasks) { task.Invoke(); } BuildServiceProvider(); SillycoreApp.Instance = new SillycoreApp(DataStore); foreach (var task in _afterBuildTasks) { task.Invoke(); } SillycoreApp.Instance.Started(); return(SillycoreApp.Instance); }
/// <summary> /// Configures the service collection using the given <see cref="IServiceConfigurator"/>. /// </summary> /// <param name="services">The service collection</param> /// <param name="configurator">The service configurator</param> /// <returns>The service collection after changes</returns> /// <exception cref="ArgumentNullException"></exception> public static IServiceCollection ConfigureUsing(this IServiceCollection services, IServiceConfigurator configurator) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (configurator == null) { throw new ArgumentNullException(nameof(configurator)); } configurator.Configure(services); return(services); }