当前位置: 首页>>代码示例>>C#>>正文


C# this.AddSingleton方法代码示例

本文整理汇总了C#中this.AddSingleton方法的典型用法代码示例。如果您正苦于以下问题:C# this.AddSingleton方法的具体用法?C# this.AddSingleton怎么用?C# this.AddSingleton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在this的用法示例。


在下文中一共展示了this.AddSingleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddWebFileSystems

        public static IServiceCollection AddWebFileSystems(this IServiceCollection services)
        {
            services.AddSingleton<IClientFolder, WebSiteFolder>();
            services.AddSingleton<IVirtualPathProvider, DefaultVirtualPathProvider>();

            return services;
        }
开发者ID:nicklv,项目名称:Orchard2,代码行数:7,代码来源:ServiceCollectionExtensions.cs

示例2: AddDD4T

        public static void AddDD4T(this IServiceCollection services)
        {
            //var configuration = new Configuration()
            //     .AddJsonFile("config.json")
            //     .AddEnvironmentVariables();

            //var config = JsonConvert.DeserializeObject<DD4TConfiguration>()
            //var x = configuration.GetSubKey("DD4TAppSettings");

            services.AddSingleton<IPublicationResolver, DefaultPublicationResolver>();
            services.AddSingleton<ILogger, NullLogger>();
            services.AddSingleton<ICacheAgent, NullCacheAgent>();
            services.AddSingleton<IDD4TConfiguration, DD4TConfiguration>();
            //services.Configure<DD4TConfiguration>(configuration.GetSubKey("DD4TAppSettings"));

            services.AddTransient<ISerializerService, JSONSerializerService>();

            services.AddTransient<IPageProvider, TridionPageProvider>();
            services.AddTransient<IComponentPresentationProvider, ComponentPresentationProvider>();
            services.AddTransient<ILinkProvider, LinkProvider>();

            services.AddTransient<IFactoriesFacade, FactoriesFacade>();
            services.AddTransient<IPageFactory, PageFactory>();
            services.AddTransient<IComponentFactory, ComponentFactory>();
            services.AddTransient<IComponentPresentationFactory, ComponentPresentationFactory>();
            services.AddTransient<IBinaryFactory, BinaryFactory>();
            services.AddTransient<ILinkFactory, LinkFactory>();
            services.AddTransient<IFactoriesFacade, FactoriesFacade>();
        }
开发者ID:sshibani,项目名称:dd4t-vnext,代码行数:29,代码来源:IServiceCollectionExtensions.cs

示例3: ConfigureAuthorization

        public static void ConfigureAuthorization(this IServiceCollection services)
        {
            services.AddIdentity<ApplicationUser, IdentityRole>()
                .AddEntityFrameworkStores<SecurityDbContext>()
                .AddDefaultTokenProviders();

            services.AddAuthorization(options =>
            {
                options.AddPolicy("RequireClimePolicyTest", policy =>
                {
                    policy.RequireClaim("RequireClimePolicyTest");
                });

                options.AddPolicy("RequireRolePolicyTest", policy =>
                {
                    policy.RequireRole("RequireRolePolicyTest");
                });

                options.AddPolicy("RequirementBasedPolicyTest", policy =>
                {
                    policy.AddRequirements(new TestRequirement(preSatisfied: true));
                });
            });

            services.AddSingleton<IAuthorizationHandler, ResourceBasedAuthorizationHandler>();
            services.AddSingleton<IAuthorizationHandler, RequirementBasedAuthorizationHandler>();
        }
开发者ID:KoshelevS,项目名称:hunter,代码行数:27,代码来源:SecurityModule.cs

示例4: AddFileSystems

        public static IServiceCollection AddFileSystems(this IServiceCollection services)
        {
            services.AddSingleton<IAppDataFolderRoot, AppDataFolderRoot>();
            services.AddSingleton<IAppDataFolder, PhysicalAppDataFolder>();

            return services;
        }
开发者ID:adwardliu,项目名称:Orchard2,代码行数:7,代码来源:ServiceCollectionExtensions.cs

示例5: AddBrickPile

        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>()));
        }
开发者ID:marcuslindblom,项目名称:aspnet5,代码行数:29,代码来源:ServiceCollectionExtensions.cs

示例6: AddOnlineTvDatabase

 public static IServiceCollection AddOnlineTvDatabase(this IServiceCollection services)
 {
     services.AddSingleton<IOnlineTvDatabase, OnlineTvDatabaseClient>();
     services.AddScoped<IHttpClient, HttpClient>();
     services.AddSingleton<IObjectUrlFactory, ObjectUrlFactory>();
     services.AddScoped<IObjectUrlBuilder<GetSeriesInput>, GetSeriesUrlBuilder>();
     return services;
 }
开发者ID:freemsly,项目名称:Online-TV-Database.NET,代码行数:8,代码来源:OnlineTvDatabaseExtensions.cs

示例7: AddUmbracoCore

        public static IServiceCollection AddUmbracoCore(this IServiceCollection services)
        {
            services.AddSingleton<IUmbracoAssemblyProvider, ReferencedAssemblyProvider>();
            services.AddSingleton<TypeHelper>();
            services.AddSingleton<ITypeFinder, TypeFinder>();

            return services;
        }
开发者ID:vnbaaij,项目名称:Umbraco9,代码行数:8,代码来源:UmbracoCoreServices.cs

示例8: AddOgnAnalyserServices

        public static IServiceCollection AddOgnAnalyserServices(this IServiceCollection sp, OGNClientSettings settings)
        {
            sp.AddSingleton<APRSClient>();
            sp.AddSingleton<AircraftTrackAnalyser>();
            sp.AddSingleton<OGNClientSettings>(r => settings);

            return sp;
        }
开发者ID:sgacond,项目名称:OGNAnalyser,代码行数:8,代码来源:OGNAnalyser.cs

示例9: AddDomainEntity

 public static IServiceCollection AddDomainEntity(this IServiceCollection service)
 {
     service.AddSingleton<IRepository<Item>, Repository<Item>>();
     service.AddSingleton<IRepository<ItemType>, Repository<ItemType>>();
     service.AddSingleton<IRepository<Menu>, Repository<Menu>>();
     service.AddSingleton<IRepository<ItemTrace>, Repository<ItemTrace>>();
     return service;
 }
开发者ID:Blessky,项目名称:Lx,代码行数:8,代码来源:RegisterEntity.cs

示例10: AddOpenIdConnectServer

        public static IServiceCollection AddOpenIdConnectServer(this IServiceCollection services)
        {
            services.AddWebEncoders();
            services.AddSingleton<HtmlEncoder>();
            services.AddSingleton<UrlEncoder>();

            return services;
        }
开发者ID:Fosol,项目名称:Example.Oauth,代码行数:8,代码来源:OpenIdConnectServerExtensions.cs

示例11: AddLog4NetServices

 /// <summary>
 /// 添加Log4Net日志功能相关映射信息
 /// </summary>
 public static void AddLog4NetServices(this IServiceCollection services)
 {
     if (OSharpConfig.LoggingConfigReseter == null)
     {
         OSharpConfig.LoggingConfigReseter = new Log4NetLoggingConfigReseter();
     }
     services.AddSingleton<IBasicLoggingInitializer, Log4NetLoggingInitializer>();
     services.AddSingleton<Log4NetLoggerAdapter>();
 }
开发者ID:donnieyoung,项目名称:osharp,代码行数:12,代码来源:ServiceCollectionExtensions.cs

示例12: UseSmtp4dev

        public static void UseSmtp4dev(this IServiceCollection services)
        {
            SettingsStore settingsStore = new SettingsStore();
            services.AddSingleton<ISettingsStore>(settingsStore);

            MessageStore messageStore = new MessageStore();
            services.AddSingleton<IMessageStore>(messageStore);

            services.AddTransient<ISmtp4devEngine, Smtp4devEngine>();
        }
开发者ID:rnwood,项目名称:smtp4dev,代码行数:10,代码来源:ServiceExtensions.cs

示例13: AddJsonLocalization

 public static IServiceCollection AddJsonLocalization(this IServiceCollection services, Action<JsonStringLocalizerOptions> options)
 {
     if (options != null)
     {
         services.Configure(options);
     }
     services.AddSingleton<IStringLocalizerFactory, JsonStringLocalizerFactory>();
     services.AddSingleton(typeof(IStringLocalizer<>), typeof(JsonStringLocalizer<>));
     return services;
 }
开发者ID:folkelib,项目名称:Folke.Localization.Json,代码行数:10,代码来源:JsonLocalizationServiceCollectionExtensions.cs

示例14: AddExternalTemplates

        /// <summary>
        /// Adds ExternalTemplates services.
        /// </summary>
        public static IServiceCollection AddExternalTemplates(this IServiceCollection services)
        {
            services.AddSingleton<IGeneratorOptions, GeneratorOptions>(
                provider => provider.GetRequiredService<IOptions<GeneratorOptions>>().Value);
            services.AddSingleton<IFilesProvider, FilesProvider>();
            services.AddSingleton<ICoreGenerator, CoreGenerator>();
            services.AddSingleton<IGenerator, Generator>();

            return services;
        }
开发者ID:mrahhal,项目名称:ExternalTemplates,代码行数:13,代码来源:ServiceExtensions.cs

示例15: AddContextAccessor

        public static IServiceCollection AddContextAccessor(this IServiceCollection self)
        {
            if (self.Count(x => x.ServiceType == typeof(IHttpContextAccessor)) == 0)
                self.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

            if (self.Count(x => x.ServiceType == typeof(IActionContextAccessor)) == 0)
                self.AddSingleton<IActionContextAccessor, ActionContextAccessor>();

            return self;
        }
开发者ID:yonglehou,项目名称:dotNETCore-Extensions,代码行数:10,代码来源:HttpContextAccessorExtensions.cs


注:本文中的this.AddSingleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。