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


C# ServiceProvider.Add方法代码示例

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


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

示例1: TestAddDuplicateService2

 public void TestAddDuplicateService2()
 {
   ServiceProvider provider = new ServiceProvider();
   provider.Add<ILog>(new ServiceCreatorCallback<ILog>(ServiceRequested));
   ILog log1 = new NoLog();
   provider.Add<ILog>(log1);
 }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:7,代码来源:ServiceTest.cs

示例2: TestAddDuplicateService1

 public void TestAddDuplicateService1()
 {
   ServiceProvider provider = new ServiceProvider();
   ILog log1 = new NoLog();
   ILog log2 = new NoLog();
   provider.Add<ILog>(log1);
   provider.Add<ILog>(log2);
 }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:8,代码来源:ServiceTest.cs

示例3: TestServiceCreatorCallback

 public void TestServiceCreatorCallback()
 {
   ServiceProvider provider = new ServiceProvider();
   provider.Add<ILog>(new ServiceCreatorCallback<ILog>(ServiceRequested));
   ILog log = provider.Get<ILog>();
   Assert.IsNotNull(log);
 }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:7,代码来源:ServiceTest.cs

示例4: Create

        /// <summary>
        /// Create a default ServiceProvider with the given settings.
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static IServiceProvider Create(IDictionary<string, string> settings, Action<ServiceProvider> configuration)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            var services = new ServiceProvider();
            DoCallback(settings, (service, implementation) => services.Add(service, implementation));
            configuration(services);
            return services;
        }
开发者ID:Kstal,项目名称:Microsoft.Owin,代码行数:22,代码来源:ServicesFactory.cs

示例5: AddCodeGenerationServices

        private static void AddCodeGenerationServices(ServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            serviceProvider.Add(typeof(IApplicationEnvironment), PlatformServices.Default.Application);
            serviceProvider.Add(typeof(IRuntimeEnvironment), PlatformServices.Default.Runtime);
            serviceProvider.Add(typeof(IAssemblyLoadContextAccessor), PlatformServices.Default.AssemblyLoadContextAccessor);
            serviceProvider.Add(typeof(IAssemblyLoaderContainer), PlatformServices.Default.AssemblyLoaderContainer);
            serviceProvider.Add(typeof(ILibraryManager), PlatformServices.Default.LibraryManager);
            serviceProvider.Add(typeof(ILibraryExporter), CompilationServices.Default.LibraryExporter);
            serviceProvider.Add(typeof(ICompilerOptionsProvider), CompilationServices.Default.CompilerOptionsProvider);

            //Ordering of services is important here
            serviceProvider.Add(typeof(ILogger), new ConsoleLogger());
            serviceProvider.Add(typeof(IFilesLocator), new FilesLocator());

            serviceProvider.AddServiceWithDependencies<ICodeGeneratorAssemblyProvider, DefaultCodeGeneratorAssemblyProvider>();
            serviceProvider.AddServiceWithDependencies<ICodeGeneratorLocator, CodeGeneratorsLocator>();

            serviceProvider.AddServiceWithDependencies<ICompilationService, RoslynCompilationService>();
            serviceProvider.AddServiceWithDependencies<ITemplating, RazorTemplating>();

            serviceProvider.AddServiceWithDependencies<IPackageInstaller, PackageInstaller>();

            serviceProvider.AddServiceWithDependencies<IModelTypesLocator, ModelTypesLocator>();
            serviceProvider.AddServiceWithDependencies<ICodeGeneratorActionsService, CodeGeneratorActionsService>();
            serviceProvider.AddServiceWithDependencies<IDbContextEditorServices, DbContextEditorServices>();
            serviceProvider.AddServiceWithDependencies<IEntityFrameworkService, EntityFrameworkServices>();
        }
开发者ID:leloulight,项目名称:Scaffolding,代码行数:32,代码来源:Program.cs

示例6: Create

 public static ServiceProvider Create()
 {
     var services = new ServiceProvider();
     DoCallback((service, implementation) => services.Add(service, implementation));
     return services;
 }
开发者ID:464884492,项目名称:Mvc,代码行数:6,代码来源:MvcServices.cs


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