public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddLogging(); services.Add(new ServiceDescriptor(typeof(ISeriesLogic), typeof(SeriesLogic.SeriesLogic), ServiceLifetime.Transient)); services.Add(new ServiceDescriptor(typeof(ISeriesCache), typeof(InMemoryCache), ServiceLifetime.Singleton)); services.Add(new ServiceDescriptor(typeof(ISeriesEvaluator), typeof(FibonacciSeriesEvaluator), ServiceLifetime.Transient)); services.Add(new ServiceDescriptor(typeof(ISeriesEvaluator), typeof(PrimeSeriesEvaluator), ServiceLifetime.Transient)); }
public void Configure(IServiceCollection serviceCollection) { // MVC is already registering IMemoryCache as host singleton. We are registering it again // in this module so that there is one instance for each tenant. serviceCollection.Add(ServiceDescriptor.Singleton<IMemoryCache, MemoryCache>()); // LocalCache is registered as transient as its implementation resolves IMemoryCache, thus // there is no state to keep in its instance. serviceCollection.Add(ServiceDescriptor.Transient<IDistributedCache, MemoryDistributedCache>()); }
// This method gets called by the runtime. public void ConfigureServices(IServiceCollection services) { // Add MVC services to the services container. services.AddMvc(); var d = new ServiceDescriptor(typeof(IUnitOfWork), new UnitOfWork()); services.Add(d); }
public void Register(IServiceCollection serviceCollection) { foreach (var service in _serviceCollection) { serviceCollection.Add(service); } }
public void Configure(IServiceCollection serviceCollection) { // MVC is already registering IMemoryCache. Any module that would add another implementation // would take over the default one as the last registered service will be resolved. // serviceCollection.Add(ServiceDescriptor.Singleton<IMemoryCache, MemoryCache>()); // LocalCache is registered as Transient as its implementation resolves IMemoryCache, thus // there is no state to keep in its instance. serviceCollection.Add(ServiceDescriptor.Transient<IDistributedCache, LocalCache>()); }
private static void MergeServiceDescriptions(IServiceCollection serviceCollection, IEnumerable<ServiceDescriptor> serviceDescriptors) { var excludedServiceDescriptors = serviceCollection.Where(service => serviceDescriptors.Contains(service) == false); foreach (var descriptor in excludedServiceDescriptors) { serviceCollection.Remove(descriptor); } foreach (var descriptor in serviceDescriptors) { serviceCollection.Add(descriptor); } }
private void RegisterInternal <T>(string reactionName) where T : ReactionModuleBase { if (!_modules.TryGetValue(reactionName, out var moduleList) || moduleList == null) { moduleList = new HashSet <Type>(); _modules[reactionName] = moduleList; } if (moduleList.Add(typeof(T))) { _serviceProvider?.Add(new ServiceDescriptor(typeof(T), typeof(T), ServiceLifetime.Transient)); } }
public void RegisterAssembly(IServiceCollection services, AssemblyName assemblyName, string path = "") { var loadContext = PlatformServices.Default.AssemblyLoadContextAccessor.Default; var loader = new DirectoryLoader(path, loadContext); var assembly = loader.Load(assemblyName); foreach (var type in assembly.DefinedTypes) { var dependencyAttributes = type.GetCustomAttributes<DependencyAttribute>(); // Each dependency can be registered as various types foreach (var serviceDescriptor in dependencyAttributes.Select(dependencyAttribute => dependencyAttribute.BuiildServiceDescriptor(type))) { services.Add(serviceDescriptor); } } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //This can be injected to any service, controller... services.Add( new ServiceDescriptor( typeof (IOptions<RedisCacheOptions>), Configuration.Get<RedisCacheOptions>("RedisCacheOptions") ) ); //At the moment the redis cache implements the wrong interface, that's why the OwnRedisCache services.AddSingleton<IDistributedCache, OwnRedisCache>(); services.AddSession(o => { o.IdleTimeout = TimeSpan.FromMinutes(15); }); services.AddMvc(); }
private static void WireUpDbContexts(IServiceCollection services, IConfiguration configuration) { var cmsConnString = configuration["Data:cmsconnection:ConnectionString"]; var authConnString = configuration["Data:authconnection:ConnectionString"]; var connectionStrings = new Dictionary<Type, string> { {typeof (AuthDbContext), authConnString}, {typeof (ElmahDbContext), cmsConnString}, {typeof (ComponentsDbContext), cmsConnString} }; var serviceDescriptor = new ServiceDescriptor(typeof(IDbContextFactory), new DbContextFactory(connectionStrings)); services.Add(serviceDescriptor); services.AddSingleton<IDbContextScopeFactory, DbContextScopeFactory>(); services.AddSingleton<IAmbientDbContextLocator, AmbientDbContextLocator>(); }
public void RegisterAssembly(IServiceCollection services, AssemblyName assemblyName) { var assembly = _loader.Load(assemblyName.Name); foreach (var type in assembly.DefinedTypes) { var taskInterface = type.GetInterface(_options.InjectFromInterfaceName, true); if (taskInterface == null) continue; var dependencyAttributes = type.GetCustomAttributes<Attributes.DependencyAttribute>(); // Each dependency can be registered as various types foreach (var serviceDescriptor in dependencyAttributes.Select(dependencyAttribute => dependencyAttribute.BuiildServiceDescriptor(type))) { services.Add(serviceDescriptor); } } }
public void Populate(IServiceCollection services) { foreach (var type in Types) { var typeInfo = type.GetTypeInfo(); var attribute = typeInfo.GetCustomAttribute<ServiceDescriptorAttribute>(); if (attribute == null) { continue; } var serviceType = attribute.ServiceType ?? type; var descriptor = new ServiceDescriptor(serviceType, type, attribute.Lifetime); services.Add(descriptor); } }
static IServiceCollection FluentAdd(this IServiceCollection services, ServiceDescriptor descriptor) { services?.Add(descriptor); return(services); }
internal static void Register(IServiceCollection serviceCollection) { serviceCollection.Add(ServiceDescriptor.Instance(typeof(DataActionTokenResolver), new DataActionTokenResolver())); }
internal static void Register(IServiceCollection serviceCollection) { serviceCollection.Add(ServiceDescriptor.Singleton(new DataActionTokenResolver())); }
/// <inheritdoc /> public void Load(IServiceCollection services) { EnsureArg.IsNotNull(services, nameof(services)); services.AddSingleton <IUrlResolver, UrlResolver>(); services.AddSingleton <IBundleFactory, BundleFactory>(); services.AddSingleton <IReferenceSearchValueParser, ReferenceSearchValueParser>(); services.Add <SearchParameterDefinitionManager>() .Singleton() .AsSelf() .AsService <ISearchParameterDefinitionManager>() .AsService <IHostedService>(); services.Add <SearchableSearchParameterDefinitionManager>() .Singleton() .AsSelf() .AsDelegate <ISearchParameterDefinitionManager.SearchableSearchParameterDefinitionManagerResolver>(); services.Add <SupportedSearchParameterDefinitionManager>() .Singleton() .AsSelf() .AsService <ISupportedSearchParameterDefinitionManager>(); services.Add <SearchParameterStatusManager>() .Singleton() .AsSelf() .AsImplementedInterfaces(); services.Add <FilebasedSearchParameterStatusDataStore>() .Transient() .AsSelf() .AsService <ISearchParameterStatusDataStore>() .AsDelegate <FilebasedSearchParameterStatusDataStore.Resolver>(); services.Add <SearchParameterSupportResolver>() .Singleton() .AsSelf() .AsImplementedInterfaces(); // TypedElement based converters // These always need to be added as they are also used by the SearchParameterSupportResolver services.TypesInSameAssemblyAs <IFhirNodeToSearchValueTypeConverter>() .AssignableTo <IFhirNodeToSearchValueTypeConverter>() .Singleton() .AsService <IFhirNodeToSearchValueTypeConverter>(); services.Add <FhirNodeToSearchValueTypeConverterManager>() .Singleton() .AsSelf() .AsService <IFhirNodeToSearchValueTypeConverterManager>(); services.Add <CodeSystemResolver>() .Singleton() .AsSelf() .AsImplementedInterfaces(); if (_configuration.CoreFeatures.UseTypedElementIndexer) { services.AddSingleton <ISearchIndexer, TypedElementSearchIndexer>(); } else { services.TypesInSameAssemblyAs <IFhirElementToSearchValueTypeConverter>() .AssignableTo <IFhirElementToSearchValueTypeConverter>() .Singleton() .AsSelf() .AsService <IFhirElementToSearchValueTypeConverter>(); services.Add <FhirElementToSearchValueTypeConverterManager>() .Singleton() .AsSelf() .AsService <IFhirElementToSearchValueTypeConverterManager>(); services.AddSingleton <ISearchIndexer, SearchIndexer>(); } services.AddSingleton <ISearchParameterExpressionParser, SearchParameterExpressionParser>(); services.AddSingleton <IExpressionParser, ExpressionParser>(); services.AddSingleton <ISearchOptionsFactory, SearchOptionsFactory>(); services.AddSingleton <IReferenceToElementResolver, LightweightReferenceToElementResolver>(); services.Add <CompartmentDefinitionManager>() .Singleton() .AsSelf() .AsService <IHostedService>() .AsService <ICompartmentDefinitionManager>(); services.Add <CompartmentIndexer>() .Singleton() .AsSelf() .AsService <ICompartmentIndexer>(); services.AddSingleton <ISearchParameterValidator, SearchParameterValidator>(); services.AddSingleton <SearchParameterFilterAttribute>(); services.AddSingleton <ISearchParameterUtilities, SearchParameterUtilities>(); }
private static void RunTestWithRegValues(IServiceCollection services, Dictionary<string, object> regValues) { WithUniqueTempRegKey(registryKey => { foreach (var entry in regValues) { registryKey.SetValue(entry.Key, entry.Value); } var policyResolver = new RegistryPolicyResolver(registryKey); services.Add(policyResolver.ResolvePolicy()); }); }
public void ConfigureServices(IServiceCollection serviceCollection) { serviceCollection.Add <IUsersService, UsersService>(); serviceCollection.Add <IProblemsService, ProblemsService>(); serviceCollection.Add <ISubmissionsService, SubmissionsService>(); }
public static IServiceCollection AddPipelineCoordinator <TOpMgr, TContext>(this IServiceCollection services, Assembly assembly, IEnumerable <Type> forcedImplementations) where TOpMgr : IPipelineCoordinator <TContext> where TContext : IPipelineContext, new() { // Pipeline Coordinator services.Add(new ServiceDescriptor(typeof(IPipelineCoordinator <TContext>), typeof(TOpMgr), ServiceLifetime.Transient)); // Operations for IList<> injection assembly .DefinedTypes .Where(x => x.GetInterfaces().Contains(typeof(IPipelineOperation <TContext>)) && !x.GetInterfaces().Contains(typeof(IPipelineOperationAsync <TContext>)) && !x.IsInterface ) .ToList() .ForEach(t => services.Add(new ServiceDescriptor(typeof(IPipelineOperation <TContext>), t, ServiceLifetime.Singleton)) ); // Async Operations for IList<> injection assembly .DefinedTypes .Where(x => x.GetInterfaces().Contains(typeof(IPipelineOperationAsync <TContext>)) && !x.IsInterface ) .ToList() .ForEach(t => services.Add(new ServiceDescriptor(typeof(IPipelineOperationAsync <TContext>), t, ServiceLifetime.Singleton)) ); // Operations for IReadOnlyDictionary<> injection services.AddSingleton <IReadOnlyDictionary <Type, IPipelineOperation <TContext> > >(sp => { // Grab all operations var ops = sp.GetRequiredService <IEnumerable <IPipelineOperation <TContext> > >(); // Resolve multiple implementations of operations in the ops collection var distinctOps = ResolveDuplicateRegistrations <IPipelineOperation <TContext>, TContext>(ops.ToList(), forcedImplementations); // Auto-Convert to IDictionary except for the manually registered types var opsDict = distinctOps.ToDictionary(x => GetOperationInterfaceType <TContext>(x.GetType())); return(new ReadOnlyDictionary <Type, IPipelineOperation <TContext> >(opsDict)); }); // Async Operations for IReadOnlyDictionary<> injection services.AddSingleton <IReadOnlyDictionary <Type, IPipelineOperationAsync <TContext> > >(sp => { // Grab all operations var ops = sp.GetRequiredService <IEnumerable <IPipelineOperationAsync <TContext> > >(); // Resolve multiple implementations of operations in the ops collection var distinctOps = ResolveDuplicateRegistrations <IPipelineOperationAsync <TContext>, TContext>(ops.ToList(), forcedImplementations); // Auto-Convert to IDictionary except for the manually registered types var opsDict = distinctOps.ToDictionary(x => GetOperationInterfaceType <TContext>(x.GetType())); return(new ReadOnlyDictionary <Type, IPipelineOperationAsync <TContext> >(opsDict)); }); return(services); }
private void AddJsonOptions(IServiceCollection services) { services.Add(new ServiceDescriptor(typeof(ApiSettings), Configuration.GetSection(nameof(ApiSettings)) .Get <ApiSettings>())); }
public static IServiceCollection AddZXLRepository(this IServiceCollection services, ServiceLifetime lifeTime) { services.Add(new ServiceDescriptor(typeof(IUnitOfWork <>), typeof(UnitOfWork <>), lifeTime)); services.Add(new ServiceDescriptor(typeof(IRepository <>), typeof(Repository <>), lifeTime)); return(services); }
public override void Register(Type queryType, Type resultType, Type handlerType) { _services.Add(new ServiceDescriptor(handlerType, handlerType, _lifetime)); base.Register(queryType, resultType, handlerType); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.Add(new ServiceDescriptor(typeof(INegocio), new Negocio(new Logger()))); services.Add(new ServiceDescriptor(typeof(IMiLogger), new Logger())); }
// This method gets called by the runsize. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddAutoMapper(typeof(Startup)); //BuisnessLayerL services.Add(new ServiceDescriptor(typeof(ISupplierCreateService), typeof(SupplierCreateService), ServiceLifetime.Scoped)); services.Add(new ServiceDescriptor(typeof(ISupplierGetService), typeof(SupplierGetService), ServiceLifetime.Scoped)); services.Add(new ServiceDescriptor(typeof(ISupplierUpdateService), typeof(SupplierUpdateService), ServiceLifetime.Scoped)); services.Add(new ServiceDescriptor(typeof(IBuyerCreateService), typeof(BuyerCreateService), ServiceLifetime.Scoped)); services.Add(new ServiceDescriptor(typeof(IBuyerGetService), typeof(BuyerGetService), ServiceLifetime.Scoped)); services.Add(new ServiceDescriptor(typeof(IBuyerUpdateService), typeof(BuyerUpdateService), ServiceLifetime.Scoped)); services.Add(new ServiceDescriptor(typeof(ITightsCreateService), typeof(TightsCreateService), ServiceLifetime.Scoped)); services.Add(new ServiceDescriptor(typeof(ITightsGetService), typeof(TightsGetService), ServiceLifetime.Scoped)); services.Add(new ServiceDescriptor(typeof(ITightsUpdateService), typeof(TightsUpdateService), ServiceLifetime.Scoped)); //DataAccess services.Add(new ServiceDescriptor(typeof(ISupplierDataAccess), typeof(SupplierDataAccess), ServiceLifetime.Transient)); services.Add(new ServiceDescriptor(typeof(IBuyerDataAccess), typeof(BuyerDataAccess), ServiceLifetime.Transient)); services.Add(new ServiceDescriptor(typeof(ITightsDataAccess), typeof(TightsDataAccess), ServiceLifetime.Transient)); //DB Contexts services.AddDbContext <SupplierContext>(options => options.UseSqlServer(this.Configuration.GetConnectionString("Suppliers"))); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddRazorPages(); services.Add(new ServiceDescriptor(typeof(UnamedWebsiteService), new UnamedWebsiteService(Configuration.GetConnectionString("DefaultConnection")))); services.AddControllers(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.Add(new ServiceDescriptor(typeof(UserInformationContext), new UserInformationContext())); services.Add(new ServiceDescriptor(typeof(NflProjectionsContext), new NflProjectionsContext())); // In production, the React files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/build"; }); //Adding Authentication Services /////////////////////////////////// AUTHO services.AddAuthentication(options => { options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; }) .AddCookie() .AddOpenIdConnect("Auth0", options => { // Set the authority to your Auth0 domain options.Authority = $"https://{Configuration["Auth0:Domain"]}"; // Configure the Auth0 Client ID and Client Secret options.ClientId = Configuration["Auth0:ClientId"]; options.ClientSecret = Configuration["Auth0:ClientSecret"]; // Set response type to code options.ResponseType = "code"; // Configure the scope options.Scope.Clear(); options.Scope.Add("openid"); // Set the callback path, so Auth0 will call back to http://localhost:5000/signin-auth0 // Also ensure that you have added the URL as an Allowed Callback URL in your Auth0 dashboard options.CallbackPath = new PathString("https://localhost:5001/home"); // Configure the Claims Issuer to be Auth0 options.ClaimsIssuer = "Auth0"; options.Events = new OpenIdConnectEvents { // handle the logout redirection OnRedirectToIdentityProviderForSignOut = (context) => { var logoutUri = $"https://{Configuration["Auth0:Domain"]}/v2/logout?client_id={Configuration["Auth0:ClientId"]}"; var postLogoutUri = context.Properties.RedirectUri; if (!string.IsNullOrEmpty(postLogoutUri)) { if (postLogoutUri.StartsWith("/")) { // transform to absolute var request = context.Request; postLogoutUri = request.Scheme + "://" + request.Host + request.PathBase + postLogoutUri; } logoutUri += $"&returnTo={ Uri.EscapeDataString(postLogoutUri)}"; } context.Response.Redirect(logoutUri); context.HandleResponse(); return(Task.CompletedTask); } }; }); /////////////////////////////////// AUTHO }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Add(new ServiceDescriptor(typeof(MentorContext), new MentorContext(Configuration.GetConnectionString("DefaultConnection")))); services.AddControllers(); }
public void ConfigureServices(IServiceCollection serviceCollection) { serviceCollection.Add <IUsersService, UsersService>(); serviceCollection.Add <ITripsService, TripsService>(); }
public static IServiceCollection AddDbContext(this IServiceCollection services, Type dbContextType, ServiceLifetime lifetime) { services.Add(new ServiceDescriptor(typeof(DbContext), provider => provider.GetService(dbContextType), lifetime)); return(services); }
private static IFhirServerBuilder AddCosmosDbPersistence(this IFhirServerBuilder fhirServerBuilder, IConfiguration configuration) { IServiceCollection services = fhirServerBuilder.Services; services.AddCosmosDb(); services.Configure <CosmosCollectionConfiguration>(Constants.CollectionConfigurationName, cosmosCollectionConfiguration => configuration.GetSection("FhirServer:CosmosDb").Bind(cosmosCollectionConfiguration)); services.Add <CosmosFhirDataStore>() .Scoped() .AsSelf() .AsImplementedInterfaces(); services.Add <CosmosTransactionHandler>() .Scoped() .AsSelf() .AsImplementedInterfaces(); services.Add <FhirCollectionUpgradeManager>() .Singleton() .AsSelf() .AsService <IUpgradeManager>(); services.Add <FhirDocumentQueryLogger>() .Singleton() .AsService <IFhirDocumentQueryLogger>(); services.Add <CollectionInitializer>(sp => { var config = sp.GetService <CosmosDataStoreConfiguration>(); var upgradeManager = sp.GetService <FhirCollectionUpgradeManager>(); var loggerFactory = sp.GetService <ILoggerFactory>(); var namedCosmosCollectionConfiguration = sp.GetService <IOptionsMonitor <CosmosCollectionConfiguration> >(); var cosmosCollectionConfiguration = namedCosmosCollectionConfiguration.Get(Constants.CollectionConfigurationName); return(new CollectionInitializer( cosmosCollectionConfiguration.CollectionId, config, cosmosCollectionConfiguration.InitialCollectionThroughput, upgradeManager, loggerFactory.CreateLogger <CollectionInitializer>())); }) .Singleton() .AsService <ICollectionInitializer>(); services.Add <FhirCollectionSettingsUpdater>() .Singleton() .AsService <IFhirCollectionUpdater>(); services.Add <FhirStoredProcedureInstaller>() .Singleton() .AsService <IFhirCollectionUpdater>(); services.TypesInSameAssemblyAs <IFhirStoredProcedure>() .AssignableTo <IStoredProcedure>() .Singleton() .AsSelf() .AsService <IFhirStoredProcedure>(); services.Add <FhirCosmosDocumentQueryFactory>() .Singleton() .AsSelf(); services.Add <CosmosFhirOperationDataStore>() .Scoped() .AsSelf() .AsImplementedInterfaces(); services.Add <FhirDocumentClientInitializer>() .Singleton() .AsService <IDocumentClientInitializer>(); services.Add <CosmosResponseProcessor>() .Singleton() .AsSelf() .AsImplementedInterfaces(); return(fhirServerBuilder); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.Add(new ServiceDescriptor(typeof(JW_ManagementContext), new JW_ManagementContext(Configuration.GetConnectionString("DefaultConnection")))); }
// ******************************************************************* // Public methods. // ******************************************************************* #region Public methods /// <summary> /// This method adds Azure KeyVault repositories for the CG.Secrets library. /// </summary> /// <param name="serviceCollection">The service collection to use for /// the operation.</param> /// <param name="configuration">The configuration to use for the operation.</param> /// <param name="serviceLifetime">The service lifetime to use for the operation.</param> /// <returns>The value of the <paramref name="serviceCollection"/> parameter, /// for chaining calls together.</returns> public static IServiceCollection AddAzureRepositories( this IServiceCollection serviceCollection, IConfiguration configuration, ServiceLifetime serviceLifetime = ServiceLifetime.Scoped ) { // Validate the parameters before attempting to use them. Guard.Instance().ThrowIfNull(serviceCollection, nameof(serviceCollection)) .ThrowIfNull(configuration, nameof(configuration)); // Register the repository options. serviceCollection.ConfigureOptions <SecretRepositoryOptions>( configuration, out var repositoryOptions ); // Register the login options. LoginOptions loginOptions = null; if ("Default" == repositoryOptions.LoginType) { // Register the login options. serviceCollection.ConfigureOptions <LoginOptions, DefaultAzureLoginOptions>( configuration.GetSection("Default"), out loginOptions ); } else if ("Environment" == repositoryOptions.LoginType) { // Register the login options. serviceCollection.ConfigureOptions <LoginOptions, EnvironmentLoginOptions>( configuration.GetSection("Environment"), out loginOptions ); } else if ("ChainedToken" == repositoryOptions.LoginType) { // Register the login options. serviceCollection.ConfigureOptions <LoginOptions, ChainedTokenLoginOptions>( configuration.GetSection("ChainedToken"), out loginOptions ); } else if ("VisualStudio" == repositoryOptions.LoginType) { // Register the login options. serviceCollection.ConfigureOptions <LoginOptions, VisualStudioLoginOptions>( configuration.GetSection("VisualStudio"), out loginOptions ); } else if ("VisualStudioCode" == repositoryOptions.LoginType) { // Register the login options. serviceCollection.ConfigureOptions <LoginOptions, VisualStudioCodeLoginOptions>( configuration.GetSection("VisualStudioCode"), out loginOptions ); } else if ("ClientSecret" == repositoryOptions.LoginType) { // Register the login options. serviceCollection.ConfigureOptions <LoginOptions, ClientSecretLoginOptions>( configuration.GetSection("ClientSecret"), out loginOptions ); } else { // Panic!! throw new ArgumentException( message: $"Unknown login type detected: '{repositoryOptions.LoginType}'" ).SetDateTime() .SetOriginator(nameof(SecretsAzureServiceCollectionExtensions)); } // Register the azure client. serviceCollection.Add <SecretClient>(serviceProvider => { // Get the repository options. var repositoryOptions = serviceProvider.GetRequiredService <IOptions <SecretRepositoryOptions> >(); // Create the Azure credentials. var credential = loginOptions?.CreateCredentials(); // Create a client instance. var client = new SecretClient( new Uri($"https://{repositoryOptions.Value.KeyVaultName}.vault.azure.net/"), credential ); // Return the results. return(client); }, serviceLifetime ); // Register the repository. serviceCollection.Add <ISecretRepository, SecretRepository>(serviceLifetime); // Return the service collection. return(serviceCollection); }
private void AddDatastore(IServiceCollection services) { string projectId = Configuration["GOOGLE_PROJECT_ID"]; if (string.IsNullOrWhiteSpace(projectId)) Halt("Set the configuration variable GOOGLE_PROJECT_ID."); services.Add(new ServiceDescriptor(typeof(IBookStore), (x) => new DatastoreBookStore(projectId), ServiceLifetime.Singleton)); }
internal IServiceCollection RegisterOptions(IServiceCollection services) { // Caching services.Add(new ServiceDescriptor(typeof(IPluginCache <T>), typeof(DefaultScopedPluginCache <T>), this.cacheOptions.Lifetime)); services // Plugin-specific services .RegisterTypeOrInstance <IPluginLogger <T> >(loggerType, this.logger, this.priseServiceLifetime) .RegisterTypeOrInstance <IPluginPathProvider <T> >(pluginPathProviderType, this.pluginPathProvider, this.priseServiceLifetime) .RegisterTypeOrInstance <IAssemblyScanner <T> >(assemblyScannerType, this.assemblyScanner, this.priseServiceLifetime) .RegisterTypeOrInstance <IAssemblyScannerOptions <T> >(assemblyScannerOptionsType, this.assemblyScannerOptions, this.priseServiceLifetime) .RegisterTypeOrInstance <IPluginTypesProvider <T> >(pluginTypesProviderType, this.pluginTypesProvider, this.priseServiceLifetime) .RegisterTypeOrInstance <IPluginActivationContextProvider <T> >(pluginActivationContextProviderType, this.pluginActivationContextProvider, this.priseServiceLifetime) .RegisterTypeOrInstance <IPluginProxyCreator <T> >(proxyCreatorType, this.proxyCreator, this.priseServiceLifetime) .RegisterTypeOrInstance <ISharedServicesProvider <T> >(sharedServicesProviderType, this.sharedServicesProvider, this.priseServiceLifetime) .RegisterTypeOrInstance <IPluginAssemblyNameProvider <T> >(pluginAssemblyNameProviderType, this.pluginAssemblyNameProvider, this.priseServiceLifetime) .RegisterTypeOrInstance <IPluginAssemblyLoader <T> >(assemblyLoaderType, this.assemblyLoader, this.priseServiceLifetime) .RegisterTypeOrInstance <IRemoteTypesProvider <T> >(remoteTypesProviderType, this.remoteTypesProvider, this.priseServiceLifetime) .RegisterTypeOrInstance <IDependencyPathProvider <T> >(dependencyPathProviderType, this.dependencyPathProvider, this.priseServiceLifetime) .RegisterTypeOrInstance <IProbingPathsProvider <T> >(probingPathsProviderType, this.probingPathsProvider, this.priseServiceLifetime) .RegisterTypeOrInstance <IAssemblySelector <T> >(assemblySelectorType, this.assemblySelector, this.priseServiceLifetime) .RegisterTypeOrInstance <IPluginSelector <T> >(pluginSelectorType, this.pluginSelector, this.priseServiceLifetime) .RegisterTypeOrInstance <IDepsFileProvider <T> >(depsFileProviderType, this.depsFileProvider, this.priseServiceLifetime) .RegisterTypeOrInstance <IPluginDependencyResolver <T> >(pluginDependencyResolverType, this.pluginDependencyResolver, this.priseServiceLifetime) .RegisterTypeOrInstance <ITempPathProvider <T> >(tempPathProviderType, this.tempPathProvider, this.priseServiceLifetime) .RegisterTypeOrInstance <IHostTypesProvider <T> >(hostTypesProviderType, this.hostTypesProvider, this.priseServiceLifetime) .RegisterTypeOrInstance <IDowngradableDependenciesProvider <T> >(downgradableDependenciesProviderType, this.downgradableDependenciesProvider, this.priseServiceLifetime) .RegisterTypeOrInstance <IRemotePluginActivator <T> >(activatorType, this.activator, this.priseServiceLifetime) // Global services .RegisterTypeOrInstance <IAssemblyLoadStrategyProvider>(assemblyLoadStrategyProviderType, this.assemblyLoadStrategyProvider, this.priseServiceLifetime) .RegisterTypeOrInstance <IResultConverter>(resultConverterType, this.resultConverter, this.priseServiceLifetime) .RegisterTypeOrInstance <IParameterConverter>(parameterConverterType, this.parameterConverter, this.priseServiceLifetime) .RegisterTypeOrInstance <IRuntimePlatformContext>(runtimePlatformContextType, this.runtimePlatformContext, this.priseServiceLifetime) .RegisterTypeOrInstance <INativeAssemblyUnloader>(nativeAssemblyUnloaderType, this.nativeAssemblyUnloader, this.priseServiceLifetime) .RegisterTypeOrInstance <IHostFrameworkProvider>(hostFrameworkProviderType, this.hostFrameworkProvider, this.priseServiceLifetime) ; if (assemblyLoadOptions != null) { services .Add(new ServiceDescriptor(typeof(IAssemblyLoadOptions <T>), s => assemblyLoadOptions, this.priseServiceLifetime)); } if (assemblyLoadOptionsType != null) { services .Add(new ServiceDescriptor(typeof(IAssemblyLoadOptions <T>), assemblyLoadOptionsType, this.priseServiceLifetime)); } if (networkAssemblyLoaderOptions != null) { services.Add(new ServiceDescriptor(typeof(INetworkAssemblyLoaderOptions <T>), s => networkAssemblyLoaderOptions, this.priseServiceLifetime)); services.Add(new ServiceDescriptor(typeof(IAssemblyLoadOptions <T>), s => networkAssemblyLoaderOptions, this.priseServiceLifetime)); } if (networkAssemblyLoaderOptionsType != null) { services.Add(new ServiceDescriptor(typeof(INetworkAssemblyLoaderOptions <T>), networkAssemblyLoaderOptionsType, this.priseServiceLifetime)); services.Add(new ServiceDescriptor(typeof(IAssemblyLoadOptions <T>), networkAssemblyLoaderOptionsType, this.priseServiceLifetime)); } configureServices?.Invoke(services); // Make use of DI by providing an injected instance of the registered services above services.Add(new ServiceDescriptor(typeof(IPluginLoadOptions <T>), typeof(PluginLoadOptions <T>), this.priseServiceLifetime)); return(services); }
// This method gets called by the runtime. public void ConfigureServices(IServiceCollection services) { services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings")); // Add MVC services to the services container. services.AddMvc(); var d = new ServiceDescriptor(typeof(IUnitOfWork), new UnitOfWork()); services.Add(d); }
public static void AddTypesImplementingInCurrentAssembly <T>(this IServiceCollection serviceCollection, Lifetime lifetime) { var types = GetTypesImplementing(typeof(T), new[] { Assembly.GetCallingAssembly() }); serviceCollection.Add(lifetime, types.ToArray()); }
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.Configure<MvcOptions>(options => { var formatter = options.OutputFormatters.First(f => f is JsonOutputFormatter) as JsonOutputFormatter; formatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); formatter.SerializerSettings.DefaultValueHandling = DefaultValueHandling.Ignore; formatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }); services.AddEntityFramework() .AddSqlServer() .AddDbContext<MoodDbContext>(options => options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"])); services.Add(new ServiceDescriptor(typeof(IRepository<MenuItem>), typeof(MenuItemRepository), ServiceLifetime.Transient)); services.AddTransient<SampleDataInitializer>(); }
public void ConfigureServices(IServiceCollection services) { services.AddMvc(); var descriptor = new ServiceDescriptor(typeof(IHitCounterService), new HitCounterService(_rootPath)); services.Add(descriptor); }
public static IServiceCollection AddEntityRepository(this IServiceCollection services, ServiceLifetime lifetime) { services.Add(new ServiceDescriptor(typeof(IEntityRepository <>), typeof(EntityRepository <>), lifetime)); return(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Add(new ServiceDescriptor(typeof(ILocationRecordRepository), typeof(InMemoryLocationRecordRepository), ServiceLifetime.Scoped)); services.AddControllers(); }
protected virtual void AddModuleServices(IServiceCollection moduleServices) { // TODO: add a service that will be visible to this module moduleServices.Add<ICustomersDataSource>(new CustomersDataSource()); }
public static IServiceCollection AddDecorator <TService, TDecorator>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Transient) where TDecorator : TService { var serviceType = typeof(TService); var existingRegistrations = services.Where(sd => sd.ServiceType == serviceType).ToList(); foreach (var existingRegistration in existingRegistrations) { Func <IServiceProvider, object> instanceGetter; var isRegistrationByType = false; if (existingRegistration.ImplementationInstance != null) { instanceGetter = sp => existingRegistration.ImplementationInstance; } else if (existingRegistration.ImplementationFactory != null) { instanceGetter = sp => existingRegistration.ImplementationFactory(sp); } // ReSharper disable once AssignmentInConditionalExpression - I really need an assignment here else if (isRegistrationByType = existingRegistration.ImplementationType != null) { instanceGetter = sp => sp.GetRequiredService(existingRegistration.ImplementationType); } else { throw new InvalidOperationException("Invalid service descriptor"); } var constructor = typeof(TDecorator).GetConstructors(BindingFlags.Instance | BindingFlags.Public).Single(); var newRegistration = new ServiceDescriptor(serviceType, sp => { var constructorParameters = constructor.GetParameters(); var parameterValues = new object[constructorParameters.Length]; for (var parameterNumber = 0; parameterNumber < constructorParameters.Length; parameterNumber++) { var parameter = constructorParameters[parameterNumber]; var parameterType = parameter.ParameterType; if (parameterType != serviceType) { parameterValues[parameterNumber] = sp.GetRequiredService(parameterType); } else { parameterValues[parameterNumber] = instanceGetter(sp); } } return(constructor.Invoke(parameterValues)); }, lifetime); services.Remove(existingRegistration); services.Add(newRegistration); if (isRegistrationByType) { services.Add(new ServiceDescriptor(existingRegistration.ImplementationType, existingRegistration.ImplementationType, existingRegistration.Lifetime)); } /*TODO: answer these questions: * 1. Is simply calling sp.GetRequiredService enough for all cases? E.g., Lazy, IEnumerable etc. Is it handled already inside? Or do we need another method that hanles this? * 2. What about open generics? * 3. Are applied BindingFlags correct? Is this flexible enough? */ } return(services); }
public void ConfigureServices(IServiceCollection services) { services.AddMvc(); var d = new ServiceDescriptor(typeof(IUnitOfWork), new UnitOfWork()); services.Add(d); }
public void ConfigureServices(IServiceCollection serviceCollection) { serviceCollection.Add <IUsersService, UsersService>(); serviceCollection.Add <IAlbumsService, AlbumService>(); serviceCollection.Add <ITracksService, TrackService>(); }
// Adds a service if the service type and implementation type hasn't been added yet. This is needed for // services like IConfigureOptions<MvcOptions> or IApplicationModelProvider where you need the ability // to register multiple implementation types for the same service type. private static bool TryAddMultiRegistrationService(IServiceCollection services, ServiceDescriptor descriptor) { // This can't work when registering a factory or instance, you have to register a type. // Additionally, if any existing registrations use a factory or instance, we can't check those, but we don't // assert that because it might be added by user-code. Debug.Assert(descriptor.ImplementationType != null); if (services.Any(d => d.ServiceType == descriptor.ServiceType && d.ImplementationType == descriptor.ImplementationType)) { return false; } services.Add(descriptor); return true; }
public void ConfigureServices(IServiceCollection serviceCollection) { serviceCollection.Add <IUsersService, UsersService>(); serviceCollection.Add <IProductsService, ProductsService>(); }
// This method gets called by the runtime. public void ConfigureServices(IServiceCollection services) { // Add EF services to the services container. //services.AddEntityFramework(Configuration) // .AddSqlServer() // .AddDbContext<MoBContext>(); //// Add Identity services to the services container. //services.AddIdentity<ApplicationUser, IdentityRole>(Configuration) // .AddEntityFrameworkStores<MoBContext>(); var d = new ServiceDescriptor(typeof(IUnitOfWork), new UnitOfWork()); services.Add(d); // Add MVC services to the services container. services.AddMvc(); }
/// <inheritdoc /> public void Load(IServiceCollection services) { EnsureArg.IsNotNull(services, nameof(services)); var jsonParser = new FhirJsonParser(DefaultParserSettings.Settings); var jsonSerializer = new FhirJsonSerializer(); var xmlParser = new FhirXmlParser(); var xmlSerializer = new FhirXmlSerializer(); services.AddSingleton(jsonParser); services.AddSingleton(jsonSerializer); services.AddSingleton(xmlParser); services.AddSingleton(xmlSerializer); FhirPathCompiler.DefaultSymbolTable.AddFhirExtensions(); ResourceElement SetMetadata(Resource resource, string versionId, DateTimeOffset lastModified) { resource.VersionId = versionId; resource.Meta.LastUpdated = lastModified; return(resource.ToResourceElement()); } services.AddSingleton <IReadOnlyDictionary <FhirResourceFormat, Func <string, string, DateTimeOffset, ResourceElement> > >(_ => { return(new Dictionary <FhirResourceFormat, Func <string, string, DateTimeOffset, ResourceElement> > { { FhirResourceFormat.Json, (str, version, lastModified) => { var resource = jsonParser.Parse <Resource>(str); return SetMetadata(resource, version, lastModified); } }, { FhirResourceFormat.Xml, (str, version, lastModified) => { var resource = xmlParser.Parse <Resource>(str); return SetMetadata(resource, version, lastModified); } }, }); }); services.AddSingleton <ResourceDeserializer>(); services.Add <FormatterConfiguration>() .Singleton() .AsSelf() .AsService <IPostConfigureOptions <MvcOptions> >(); services.AddSingleton <IContentTypeService, ContentTypeService>(); services.AddSingleton <OperationOutcomeExceptionFilterAttribute>(); services.AddSingleton <ValidateContentTypeFilterAttribute>(); services.AddSingleton <ValidateExportRequestFilterAttribute>(); services.AddSingleton <ValidationQueryFilterAndParameterParserAttribute>(); // Support for resolve() FhirPathCompiler.DefaultSymbolTable.AddFhirExtensions(); services.Add <FhirJsonInputFormatter>() .Singleton() .AsSelf() .AsService <TextInputFormatter>(); services.Add <FhirJsonOutputFormatter>() .Singleton() .AsSelf() .AsService <TextOutputFormatter>(); services.Add <FhirRequestContextAccessor>() .Singleton() .AsSelf() .AsService <IFhirRequestContextAccessor>(); services.AddSingleton <CorrelationIdProvider>(_ => () => Guid.NewGuid().ToString()); // Add conformance provider for implementation metadata. services.Add <SystemConformanceProvider>() .Singleton() .AsSelf() .AsImplementedInterfaces(); services.Add <SecurityProvider>() .Singleton() .AsSelf() .AsService <IProvideCapability>(); services.TypesInSameAssembly(KnownAssemblies.All) .AssignableTo <IProvideCapability>() .Transient() .AsService <IProvideCapability>(); services.AddSingleton <IClaimsExtractor, PrincipalClaimsExtractor>(); ModelExtensions.SetModelInfoProvider(); services.Add(_ => ModelInfoProvider.Instance).Singleton().AsSelf().AsImplementedInterfaces(); // Register a factory to resolve a scope that returns all components that provide capabilities services.AddFactory <IScoped <IEnumerable <IProvideCapability> > >(); services.AddLazy(); services.AddScoped(); }
/// <summary> /// 以类型实现的接口进行服务添加,需排除 /// <see cref="ITransientDependency"/>、 /// <see cref="IScopeDependency"/>、 /// <see cref="ISingletonDependency"/>、 /// <see cref="IDependency"/>、 /// <see cref="IDisposable"/>等非业务接口,如无接口则注册自身 /// </summary> /// <param name="services">服务映射信息集合</param> /// <param name="implementationTypes">要注册的实现类型集合</param> /// <param name="lifetime">注册的生命周期类型</param> protected virtual void AddTypeWithInterfaces(IServiceCollection services, Type[] implementationTypes, LifetimeStyle lifetime) { foreach (Type implementationType in implementationTypes) { if (implementationType.IsAbstract || implementationType.IsInterface) { continue; } Type[] interfaceTypes = GetImplementedInterfaces(implementationType); if (interfaceTypes.Length == 0) { services.Add(implementationType, implementationType, lifetime); continue; } foreach (Type interfaceType in interfaceTypes) { services.Add(interfaceType, implementationType, lifetime); } } }
private static void RegisterTypes(IEnumerable <Assembly> assembliesToRegister, IServiceCollection services) { AssemblyScanner.FindValidatorsInAssemblies(assembliesToRegister).ForEach(pair => { services.Add(ServiceDescriptor.Transient(pair.InterfaceType, pair.ValidatorType)); }); }
public static void AddTypesImplementing <T>(this IServiceCollection serviceCollection, Lifetime lifetime, params Assembly[] assemblies) { var types = GetTypesImplementing(typeof(T), assemblies); serviceCollection.Add(lifetime, types.ToArray()); }
private void ConfigureJobServices(IServiceCollection services, IConfigurationRoot configurationRoot) { services.Configure <ValidationConfiguration>(configurationRoot.GetSection(ConfigurationSectionName)); services.Configure <ProcessSignatureConfiguration>(configurationRoot.GetSection(PackageSigningSectionName)); services.Configure <ValidateCertificateConfiguration>(configurationRoot.GetSection(PackageCertificatesSectionName)); services.Configure <OrchestrationRunnerConfiguration>(configurationRoot.GetSection(RunnerConfigurationSectionName)); services.Configure <GalleryDbConfiguration>(configurationRoot.GetSection(GalleryDbConfigurationSectionName)); services.Configure <ValidationDbConfiguration>(configurationRoot.GetSection(ValidationDbConfigurationSectionName)); services.Configure <ServiceBusConfiguration>(configurationRoot.GetSection(ServiceBusConfigurationSectionName)); services.Configure <EmailConfiguration>(configurationRoot.GetSection(EmailConfigurationSectionName)); services.Configure <ScanAndSignConfiguration>(configurationRoot.GetSection(ScanAndSignSectionName)); services.Configure <SymbolScanOnlyConfiguration>(configurationRoot.GetSection(SymbolScanOnlySectionName)); services.Configure <ScanAndSignEnqueuerConfiguration>(configurationRoot.GetSection(ScanAndSignSectionName)); services.Configure <FlatContainerConfiguration>(configurationRoot.GetSection(FlatContainerConfigurationSectionName)); services.Configure <SymbolsValidationConfiguration>(configurationRoot.GetSection(SymbolsValidatorSectionName)); services.Configure <SymbolsIngesterConfiguration>(configurationRoot.GetSection(SymbolsIngesterSectionName)); services.AddTransient <ConfigurationValidator>(); services.AddTransient <OrchestrationRunner>(); services.AddScoped <IEntitiesContext>(serviceProvider => new EntitiesContext( CreateDbConnection <GalleryDbConfiguration>(serviceProvider), readOnly: false) ); services.AddScoped(serviceProvider => new ValidationEntitiesContext( CreateDbConnection <ValidationDbConfiguration>(serviceProvider))); services.AddScoped <IValidationEntitiesContext>(serviceProvider => serviceProvider.GetRequiredService <ValidationEntitiesContext>()); services.AddScoped <IValidationStorageService, ValidationStorageService>(); services.Add(ServiceDescriptor.Transient(typeof(IEntityRepository <>), typeof(EntityRepository <>))); services.AddTransient <ICorePackageService, CorePackageService>(); services.AddTransient <IEntityService <Package>, PackageEntityService>(); services.AddTransient <ISubscriptionClient>(serviceProvider => { var configuration = serviceProvider.GetRequiredService <IOptionsSnapshot <ServiceBusConfiguration> >().Value; return(new SubscriptionClientWrapper(configuration.ConnectionString, configuration.TopicPath, configuration.SubscriptionName)); }); services.AddTransient <ITopicClient>(serviceProvider => { var configuration = serviceProvider.GetRequiredService <IOptionsSnapshot <ServiceBusConfiguration> >().Value; return(new TopicClientWrapper(configuration.ConnectionString, configuration.TopicPath)); }); services.AddTransient <IPackageValidationEnqueuer, PackageValidationEnqueuer>(); services.AddTransient <IValidatorProvider, ValidatorProvider>(); services.AddTransient <IValidationSetProvider <Package>, ValidationSetProvider <Package> >(); // Only one Orchestrator Message Handler will be registered. ConfigureOrchestratorMessageHandler(services, configurationRoot); services.AddTransient <IServiceBusMessageSerializer, ServiceBusMessageSerializer>(); services.AddTransient <IBrokeredMessageSerializer <PackageValidationMessageData>, PackageValidationMessageDataSerializationAdapter>(); services.AddTransient <ICriteriaEvaluator <Package>, PackageCriteriaEvaluator>(); services.AddTransient <IProcessSignatureEnqueuer, ProcessSignatureEnqueuer>(); services.AddTransient <ICloudBlobClient>(c => { var configurationAccessor = c.GetRequiredService <IOptionsSnapshot <ValidationConfiguration> >(); return(new CloudBlobClientWrapper( configurationAccessor.Value.ValidationStorageConnectionString, readAccessGeoRedundant: false)); }); services.AddTransient <ICoreFileStorageService, CloudBlobCoreFileStorageService>(); services.AddTransient <IFileDownloader, PackageDownloader>(); services.AddTransient <IStatusProcessor <Package>, PackageStatusProcessor>(); services.AddTransient <IValidationSetProvider <Package>, ValidationSetProvider <Package> >(); services.AddTransient <IValidationSetProcessor, ValidationSetProcessor>(); services.AddTransient <IBrokeredMessageSerializer <SignatureValidationMessage>, SignatureValidationMessageSerializer>(); services.AddTransient <IBrokeredMessageSerializer <CertificateValidationMessage>, CertificateValidationMessageSerializer>(); services.AddTransient <IBrokeredMessageSerializer <ScanAndSignMessage>, ScanAndSignMessageSerializer>(); services.AddTransient <IValidatorStateService, ValidatorStateService>(); services.AddTransient <ISimpleCloudBlobProvider, SimpleCloudBlobProvider>(); services.AddTransient <PackageSignatureProcessor>(); services.AddTransient <PackageSignatureValidator>(); services.AddTransient <Messaging.IServiceBusMessageSerializer, Messaging.ServiceBusMessageSerializer>(); services.AddTransient <IMessageServiceConfiguration, CoreMessageServiceConfiguration>(); services.AddTransient <IMessageService, AsynchronousEmailMessageService>(); services.AddTransient <IMessageService <Package>, PackageMessageService>(); services.AddTransient <ICommonTelemetryService, CommonTelemetryService>(); services.AddTransient <ITelemetryService, TelemetryService>(); services.AddTransient <ISubscriptionProcessorTelemetryService, TelemetryService>(); services.AddTransient <ITelemetryClient, TelemetryClientWrapper>(); services.AddTransient <IDiagnosticsService, LoggerDiagnosticsService>(); services.AddSingleton(new TelemetryClient()); services.AddTransient <IValidationOutcomeProcessor <Package>, ValidationOutcomeProcessor <Package> >(); services.AddSingleton(p => { var assembly = Assembly.GetEntryAssembly(); var assemblyName = assembly.GetName().Name; var assemblyVersion = assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "0.0.0"; var client = new HttpClient(new WebRequestHandler { AllowPipelining = true, AutomaticDecompression = (DecompressionMethods.GZip | DecompressionMethods.Deflate), }); client.Timeout = configurationRoot.GetValue <TimeSpan>(PackageDownloadTimeoutName); client.DefaultRequestHeaders.Add("User-Agent", $"{assemblyName}/{assemblyVersion}"); return(client); }); ConfigureFileServices(services, configurationRoot); ConfigureOrchestratorSymbolTypes(services); }
public static void Add <T>(this IServiceCollection serviceCollection, Lifetime lifetime) { serviceCollection.Add(typeof(T), lifetime); }
protected virtual void AddGlobalServices(IServiceCollection globalServices) { globalServices.AddNew<EnterpriseLibraryAuthorizationService, IAuthorizationService>(); _siteMapBuilderService = globalServices.AddNew<SiteMapBuilderService, ISiteMapBuilderService>(); globalServices.Add<IPostalInfoLookupService>( new PostalInfoLookupService(PostalInfoLookupDataSet.CreateLoaded())); }