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


C# IServiceProvider.GetServiceLazily方法代码示例

本文整理汇总了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>();
 }
开发者ID:Core2D,项目名称:Core2D,代码行数:25,代码来源:ProjectEditor.Model.cs

示例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>();
 }
开发者ID:Core2D,项目名称:Core2D,代码行数:9,代码来源:App.xaml.cs


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