public MiddlewareCore( RequestDelegate next, RestApiServerOptions options) { _next = next; _options = options; }
public static IServiceCollection AddRestApiServer(this IServiceCollection services, Action <RestApiServerOptions> configure = null) { var restApiServerOptions = new RestApiServerOptions(); configure?.Invoke(restApiServerOptions); services.AddSingleton(restApiServerOptions); return(services); }
public MiddlewareCore( RequestDelegate next, RestApiServerOptions options, IRestApiServerSource source, IRestApiRouteResolver restApiRouteResolver, IRestApiRequestHandlerFactory restApiRequestHandlerFactory, IDbSetExecutorFactory dbSetExecutorFactory) { _next = next; _source = source ?? throw new ArgumentNullException(nameof(source)); _options = options ?? throw new ArgumentNullException(nameof(options)); _restApiRouteResolver = restApiRouteResolver ?? throw new ArgumentNullException(nameof(restApiRouteResolver)); _restApiRequestHandlerFactory = restApiRequestHandlerFactory ?? throw new ArgumentNullException(nameof(restApiRequestHandlerFactory)); _dbSetExecutorFactory = dbSetExecutorFactory ?? throw new ArgumentNullException(nameof(IDbSetExecutorFactory)); }
public static IServiceCollection AddRestApiServer <TDbContext>(this IServiceCollection services, Action <RestApiServerOptions> configure = null) where TDbContext : DbContext { var restApiServerOptions = new RestApiServerOptions(); configure?.Invoke(restApiServerOptions); var builder = new RestApiServerSourceBuilder(); builder.AddDbContext <TDbContext>(); var source = builder.Build(); services.AddSingleton(source); services.AddSingleton(restApiServerOptions); services.AddSingleton <IRestApiRouteResolver, RestApiRouteResolver>(); services.AddSingleton <IRestApiRequestHandlerFactory, RestApiRequestHandlerFactory>(); services.AddSingleton <IDbSetExecutorFactory, DbSetExecutorFactory>(); return(services); }