public static IBlobStorageBuilder AddBlobStorage(this IServiceCollection self) { self.AddContextAccessor(); var builder = new BlobStorageBuilder(); builder.Services = self.AddRouting(); return builder; }
public static void AddBrickPile(this IServiceCollection services) { _serviceProvider = services.BuildServiceProvider(); services.AddMvc().ConfigureApplicationPartManager(manager => { var feature = new ControllerFeature(); manager.PopulateFeature(feature); services.AddSingleton<IControllerMapper>(new ControllerMapper(feature)); }); services.AddRouting(options => { options.AppendTrailingSlash = true; options.LowercaseUrls = true; }); services.Configure<MvcOptions>(options => { options.ModelBinderProviders.Insert(0, new DefaultModelBinderProvider(DocumentStore)); options.Filters.Add(typeof(PublishedFilterAttribute), 1); options.Filters.Add(typeof(AuthorizeFilterAttribute), 2); }); services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton(DocumentStore); services.AddTransient<IRouteResolverTrie>(provider => new RouteResolverTrie(provider.GetService<IDocumentStore>())); services.AddTransient<IBricsContextAccessor>(provider => new BricsContextAccessor(provider.GetService<IHttpContextAccessor>(), provider.GetService<IDocumentStore>())); }
/// <summary> /// Extension method to add the JsonRpc router services to the IoC container /// </summary> /// <param name="serviceCollection">IoC serivce container to register JsonRpc dependencies</param> /// <param name="configureOptions">Action to configure the router properties</param> /// <returns>IoC service container</returns> public static IServiceCollection AddJsonRpc(this IServiceCollection serviceCollection, Action<RpcServerConfiguration> configureOptions = null) { if (serviceCollection == null) { throw new ArgumentNullException(nameof(serviceCollection)); } RpcServerConfiguration configuration = new RpcServerConfiguration(); configureOptions?.Invoke(configuration); return serviceCollection .AddRouting() .AddAuthorization() .Configure<RpcServerConfiguration>(configureOptions ?? (options => { })) .AddSingleton<IRpcInvoker, DefaultRpcInvoker>() .AddSingleton<IRpcParser, DefaultRpcParser>() .AddSingleton<IRpcCompressor, DefaultRpcCompressor>(); }
/// <summary> /// Adds services required for routing requests. /// </summary> /// <param name="services">The <see cref="IServiceCollection"/> to add the services to.</param> /// <param name="configureOptions">The routing options to configure the middleware with.</param> /// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns> public static IServiceCollection AddRouting( this IServiceCollection services, Action<RouteOptions> configureOptions) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (configureOptions == null) { throw new ArgumentNullException(nameof(configureOptions)); } services.Configure(configureOptions); services.AddRouting(); return services; }