本文整理汇总了C#中ServiceProvider.AddServiceWithDependencies方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceProvider.AddServiceWithDependencies方法的具体用法?C# ServiceProvider.AddServiceWithDependencies怎么用?C# ServiceProvider.AddServiceWithDependencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceProvider
的用法示例。
在下文中一共展示了ServiceProvider.AddServiceWithDependencies方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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>();
}