本文整理汇总了C#中IServiceProvider.GetServiceLazily方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceProvider.GetServiceLazily方法的具体用法?C# IServiceProvider.GetServiceLazily怎么用?C# IServiceProvider.GetServiceLazily使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceProvider
的用法示例。
在下文中一共展示了IServiceProvider.GetServiceLazily方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProjectEditor
/// <summary>
/// Initialize new instance of <see cref="ProjectEditor"/> class.
/// </summary>
/// <param name="serviceProvider">The service provider.</param>
public ProjectEditor(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
_recentProjects = ImmutableArray.Create<RecentFile>();
_currentRecentProject = default(RecentFile);
_tools = _serviceProvider.GetServiceLazily<ToolBase[], ImmutableArray<ToolBase>>((tools) => tools.Where(tool => !tool.GetType().Name.StartsWith("PathTool")).ToImmutableArray());
_pathTools = _serviceProvider.GetServiceLazily<PathToolBase[], ImmutableArray<PathToolBase>>((tools) => tools.ToImmutableArray());
_views = _serviceProvider.GetServiceLazily<IView[], ImmutableArray<IView>>((views) => views.ToImmutableArray());
_log = _serviceProvider.GetServiceLazily<ILog>();
_renderers = new Lazy<ShapeRenderer[]>(() => new[] { _serviceProvider.GetService<ShapeRenderer>(), _serviceProvider.GetService<ShapeRenderer>() });
_fileIO = _serviceProvider.GetServiceLazily<IFileSystem>();
_projectFactory = _serviceProvider.GetServiceLazily<IProjectFactory>();
_shapeFactory = _serviceProvider.GetServiceLazily<IShapeFactory>();
_textClipboard = _serviceProvider.GetServiceLazily<ITextClipboard>();
_jsonSerializer = _serviceProvider.GetServiceLazily<IJsonSerializer>();
_xamlSerializer = _serviceProvider.GetServiceLazily<IXamlSerializer>();
_fileWriters = _serviceProvider.GetServiceLazily<IFileWriter[], ImmutableArray<IFileWriter>>((writers) => writers.ToImmutableArray());
_csvReader = _serviceProvider.GetServiceLazily<ITextFieldReader<XDatabase>>();
_csvWriter = _serviceProvider.GetServiceLazily<ITextFieldWriter<XDatabase>>();
_imageImporter = _serviceProvider.GetServiceLazily<IImageImporter>();
}
示例2: InitializeConverters
/// <summary>
/// Initializes converters.
/// </summary>
/// <param name="serviceProvider">The service provider.</param>
static void InitializeConverters(IServiceProvider serviceProvider)
{
ObjectToXamlStringConverter.XamlSerializer = serviceProvider.GetServiceLazily<IXamlSerializer>();
ObjectToJsonStringConverter.JsonSerializer = serviceProvider.GetServiceLazily<IJsonSerializer>();
}