public static IServiceCollection AddFrameworkServices(this IServiceCollection services, Action <IServiceProvider, FrameworkConfigurationBuilder> configure) { services.AddSingleton <IFramework>(x => { var builder = new FrameworkConfigurationBuilder(x); configure(x, builder); return(new Framework(builder.Build())); }); services.AddSingleton(x => ProxyFromFrameworkServices <ICommunicator>(x)); services.AddScoped(x => ProxyFromFrameworkServices <ICommandParser>(x)); services.AddScoped(x => ProxyFromFrameworkServices <IUserFetcher>(x)); services.AddScoped(x => ProxyFromFrameworkServices <IFrameworkReflector>(x)); return(services); }
public static IEndpointConventionBuilder MapFramework(this IEndpointRouteBuilder endpoints, Action <FrameworkConfigurationBuilder> configure) { if (endpoints == null) { throw new ArgumentNullException(nameof(endpoints)); } if (configure == null) { throw new ArgumentNullException(nameof(configure)); } var dataSource = endpoints.ServiceProvider.GetRequiredService <FrameworkEndpointDataSource>(); var configurationBuilder = new FrameworkConfigurationBuilder(dataSource); configure(configurationBuilder); endpoints.DataSources.Add(dataSource); return(dataSource); }