本文整理汇总了C#中IContext.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# IContext.GetService方法的具体用法?C# IContext.GetService怎么用?C# IContext.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContext
的用法示例。
在下文中一共展示了IContext.GetService方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VMIContextViewModel
public VMIContextViewModel( IContext context, IPluginConfigAccessor config, ILogService logService, IHelpService helpService )
{
DisplayName = "Object explorer";
Context = context;
Config = config;
HelpService = helpService;
InitializeCommands();
_plugins = new Dictionary<IPluginInfo, VMIPlugin>();
_allServices = new Dictionary<IServiceInfo, VMIService>();
_dynamicServices = new Dictionary<IServiceInfo, VMIService>();
_serviceRefs = new Dictionary<IServiceReferenceInfo, VMIService>();
_assemblies = new Dictionary<IAssemblyInfo, VMIAssembly>();
_pluginRunner = Context.GetService<PluginRunner>( true );
_pluginRunner.ApplyDone += new EventHandler<ApplyDoneEventArgs>( OnApplyDone );
NotificationService = context.GetService<INotificationService>();
Assemblies = new VMCollection<VMIAssembly, IAssemblyInfo>( PluginRunner.Discoverer.AllAssemblies, FindOrCreate );
Plugins = new VMCollection<VMIPlugin, IPluginInfo>( PluginRunner.Discoverer.AllPlugins.OrderBy( p => p.PublicName ), FindOrCreate );
AllServices = new VMCollection<VMIService, IServiceInfo>( PluginRunner.Discoverer.AllServices, FindOrCreate );
DynamicServices = new VMCollection<VMIService, IServiceInfo>( PluginRunner.Discoverer.AllServices.Where( p => p.IsDynamicService ), FindOrCreateDynamic );
Categories = new ObservableCollection<VMIFolder>();
_vmLogConfig = new VMLogConfig( this, logService );
_vmLogConfig.Initialize();
OsInfo = new VMOSInfo( this );
VMApplicationInfo = new VMApplicationInfo( this );
Dictionary<string, List<IPluginInfo>> categoryFolders = new Dictionary<string, List<IPluginInfo>>();
foreach( IPluginInfo plugin in PluginRunner.Discoverer.AllPlugins )
{
foreach( string categ in plugin.Categories )
{
List<IPluginInfo> col;
if( !categoryFolders.TryGetValue( categ, out col ) )
{
col = new List<IPluginInfo>();
col.Add( plugin );
categoryFolders.Add( categ, col );
}
else
{
col.Add( plugin );
}
}
}
foreach( KeyValuePair<string, List<IPluginInfo>> item in categoryFolders )
{
VMCollection<VMAlias<VMIPlugin>, IPluginInfo> collection = new VMCollection<VMAlias<VMIPlugin>, IPluginInfo>( item.Value, ( info ) => { return new VMAlias<VMIPlugin>( FindOrCreate( info ), null ); } );
VMIFolder folder = new VMIFolder( collection, item.Key );
Categories.Add( folder );
}
}
示例2: Initialize
public override void Initialize(IContext context)
{
base.Initialize(context);
IInterfaceMappingService mappingService = context.GetService<IInterfaceMappingService>();
Mappings.ForEach(item => mappingService.Add(context, item.InterfaceType, item.ConcreteType));
}
示例3: Initialize
public override void Initialize(IContext context)
{
base.Initialize(context);
IFactoryContext factoryContext = context.GetService<IFactoryContext>();
//TODO Extract into a IFactoryMappingService
Mappings.ForEach(item => factoryContext.Policies.Set<IBuildKeyMappingPolicy>(new BuildKeyMappingPolicy(item.ConcreteType), item.InterfaceType));
}