本文整理汇总了C#中IServiceContainer类的典型用法代码示例。如果您正苦于以下问题:C# IServiceContainer类的具体用法?C# IServiceContainer怎么用?C# IServiceContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IServiceContainer类属于命名空间,在下文中一共展示了IServiceContainer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TestCommonBody
private void TestCommonBody(IServiceContainer container, IList<String> expected)
{
IList<String> actual = container.ResolveNameTypeServices<String>();
Assert.That(actual.Count, Is.EqualTo(expected.Count));
foreach (String actualValue in actual)
Assert.True(expected.Contains(actualValue));
}
开发者ID:stdstring,项目名称:SimpleIoC.NET,代码行数:7,代码来源:ResolveExtensionsTests.cs
示例2: Detach
public void Detach(IServiceContainer container)
{
container.UnregisterService(mainForm);
mainForm.ServiceContainer = null;
mainForm = null;
}
开发者ID:killbug2004,项目名称:partcover-fork,代码行数:7,代码来源:BrowserFormFeature.cs
示例3: Attach
public void Attach(IServiceContainer container)
{
mainForm = new MainForm();
mainForm.ServiceContainer = container;
container.RegisterService(mainForm);
}
开发者ID:killbug2004,项目名称:partcover-fork,代码行数:7,代码来源:BrowserFormFeature.cs
示例4: CreateService
/// <summary>
/// This is the function that will create a new instance of the services the first time a client
/// will ask for a specific service type. It is called by the base class's implementation of
/// IServiceProvider.
/// </summary>
/// <param name="container">The IServiceContainer that needs a new instance of the service.
/// This must be this package.</param>
/// <param name="serviceType">The type of service to create.</param>
/// <returns>The instance of the service.</returns>
private object CreateService(IServiceContainer container, Type serviceType)
{
// Check if the IServiceContainer is this package.
if (container != this)
{
Debug.WriteLine("ServicesPackage.CreateService called from an unexpected service container.");
return null;
}
// Find the type of the requested service and create it.
if (typeof(SMyGlobalService).IsEquivalentTo(serviceType))
{
// Build the global service using this package as its service provider.
return new MyGlobalService(this);
}
if (typeof(SMyLocalService).IsEquivalentTo(serviceType))
{
// Build the local service using this package as its service provider.
return new MyLocalService(this);
}
// If we are here the service type is unknown, so write a message on the debug output
// and return null.
Debug.WriteLine("ServicesPackage.CreateService called for an unknown service type.");
return null;
}
开发者ID:Sunzhuokai,项目名称:VSSDK-Extensibility-Samples,代码行数:35,代码来源:ServicesPackage.cs
示例5: DesignerHost
public DesignerHost(IServiceContainer parent)
{
// Keep the parent reference around for re-use
this.parent = parent;
// Initialise container helpers
components = new Hashtable(CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default);
designers = new Hashtable();
// Initialise transaction stack
transactions = new Stack();
// Add our own services
parent.AddService(typeof(IDesignerHost), this);
parent.AddService(typeof(IContainer), this);
parent.AddService(typeof(IComponentChangeService), this);
parent.AddService(typeof(ITypeDescriptorFilterService), this);
// Add extender services
extenderProviders = new ArrayList();
parent.AddService(typeof(IExtenderListService), this);
parent.AddService(typeof(IExtenderProviderService), this);
AddExtenderProvider(this);
// Add selection service
parent.AddService(typeof(ISelectionService), new SelectionService(this));
}
开发者ID:smartmobili,项目名称:CocoaBuilder,代码行数:27,代码来源:DesignerHost.cs
示例6: InitializeEnvironment
protected virtual void InitializeEnvironment(IServiceContainer container, ConfigurationManagerWrapper.ContentSectionTable config)
{
if (config.Web != null)
{
Url.DefaultExtension = config.Web.Web.Extension;
PathData.PageQueryKey = config.Web.Web.PageQueryKey;
PathData.ItemQueryKey = config.Web.Web.ItemQueryKey;
PathData.PartQueryKey = config.Web.Web.PartQueryKey;
PathData.PathKey = config.Web.Web.PathDataKey;
if (!config.Web.Web.IsWeb)
container.AddComponentInstance("n2.webContext.notWeb", typeof(IWebContext), new ThreadContext());
if (config.Web.Web.Urls.EnableCaching)
container.AddComponent("n2.web.cachingUrlParser", typeof(IUrlParser), typeof(CachingUrlParserDecorator));
if (config.Web.MultipleSites)
container.AddComponent("n2.multipleSitesParser", typeof(IUrlParser), typeof(MultipleSitesParser));
else
container.AddComponent("n2.urlParser", typeof(IUrlParser), typeof(UrlParser));
}
if (config.Management != null)
{
SelectionUtility.SelectedQueryKey = config.Management.Paths.SelectedQueryKey;
Url.SetToken("{Selection.SelectedQueryKey}", SelectionUtility.SelectedQueryKey);
}
}
开发者ID:GrimaceOfDespair,项目名称:n2cms,代码行数:27,代码来源:ContainerConfigurer.cs
示例7: LinFuServiceLocatorAdapter
public LinFuServiceLocatorAdapter(IServiceContainer container)
{
if (container == null)
throw new ArgumentNullException("container");
_container = container;
}
开发者ID:nickspoons,项目名称:Snap,代码行数:7,代码来源:LinFuServiceLocatorAdapter.cs
示例8: UndoEngineImplication
public UndoEngineImplication(IServiceContainer provider)
: base(provider)
{
service = provider;
editToolStripMenuItem = (ToolStripMenuItem)service.GetService(typeof(ToolStripMenuItem));
cassPropertyGrid = (FilteredPropertyGrid)service.GetService(typeof(FilteredPropertyGrid));
}
开发者ID:alloevil,项目名称:A-embedded-image-processing-platform--,代码行数:7,代码来源:UndoEngineImplication.cs
示例9: AddComponentUnlessConfigured
private void AddComponentUnlessConfigured(IServiceContainer container, Type serviceType, Type instanceType, IEnumerable<Type> skipList)
{
if (skipList.Contains(serviceType))
return;
container.AddComponent(serviceType.FullName + "->" + instanceType.FullName, serviceType, instanceType);
}
开发者ID:navneetccna,项目名称:n2cms,代码行数:7,代码来源:ContainerConfigurer.cs
示例10: DefaultGetServiceBehavior
/// <summary>
/// Initializes the class with the given <paramref name="container"/> instance.
/// </summary>
/// <param name="container">The target service container.</param>
public DefaultGetServiceBehavior(IServiceContainer container)
{
_container = container;
_creator = new DefaultCreator();
_preProcessor = new CompositePreProcessor(container.PreProcessors);
_postProcessor = new CompositePostProcessor(container.PostProcessors);
}
开发者ID:sdether,项目名称:LinFu,代码行数:11,代码来源:DefaultGetServiceBehavior.cs
示例11: GetService
protected override object GetService(Type serviceType)
{
object service = base.GetService(serviceType);
if (service != null)
{
return service;
}
if (serviceType == typeof(IServiceContainer))
{
if (this._services == null)
{
this._services = new ServiceContainer(this._host);
}
return this._services;
}
if (this._services != null)
{
return this._services.GetService(serviceType);
}
if ((base.Owner.Site != null) && this._safeToCallOwner)
{
try
{
this._safeToCallOwner = false;
return base.Owner.Site.GetService(serviceType);
}
finally
{
this._safeToCallOwner = true;
}
}
return null;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:33,代码来源:SiteNestedContainer.cs
示例12: CreateService
private object CreateService(IServiceContainer container, Type serviceType)
{
if (serviceType == typeof(NpgsqlProviderObjectFactory))
return new NpgsqlProviderObjectFactory();
return null;
}
开发者ID:Qorpent,项目名称:Npgsql2,代码行数:7,代码来源:NpgsqlPackage.cs
示例13: Detach
public void Detach(IServiceContainer container)
{
container.unregisterService(MainForm);
MainForm.ServiceContainer = null;
MainForm = null;
}
开发者ID:sjeyaram,项目名称:partcover.net4,代码行数:7,代码来源:BrowserFormFeature.cs
示例14: RegisterConfiguredComponents
protected virtual void RegisterConfiguredComponents(IServiceContainer container, EngineSection engineConfig)
{
foreach (ComponentElement component in engineConfig.Components)
{
Type implementation = Type.GetType(component.Implementation);
Type service = Type.GetType(component.Service);
if (implementation == null)
throw new ComponentRegistrationException(component.Implementation);
if (service == null && !String.IsNullOrEmpty(component.Service))
throw new ComponentRegistrationException(component.Service);
if (service == null)
service = implementation;
string name = component.Key;
if (string.IsNullOrEmpty(name))
name = implementation.FullName;
if (component.Parameters.Count == 0)
{
container.AddComponent(name, service, implementation);
}
else
{
container.AddComponentWithParameters(name, service, implementation,
component.Parameters.ToDictionary());
}
}
}
开发者ID:joaohortencio,项目名称:n2cms,代码行数:31,代码来源:ContainerConfigurer.cs
示例15: Deserialize
/// <summary>
/// Parses a source code and creates a new design surface.
/// </summary>
/// <param name="serviceContainer"></param>
/// <param name="surfaceManager"></param>
/// <param name="file">The source file to deserialize.</param>
/// <returns></returns>
public DesignSurface Deserialize(DesignSurfaceManager surfaceManager, IServiceContainer serviceContainer, OpenedFile file)
{
DesignSurface surface = surfaceManager.CreateDesignSurface(serviceContainer);
IDesignerHost designerHost = surface.GetService(typeof(IDesignerHost)) as IDesignerHost;
Type componentType = CompileTypeFromFile(file);
// load base type.
surface.BeginLoad(componentType.BaseType);
// get instance to copy components and properties from.
Control instance = Activator.CreateInstance(componentType) as Control;
// add components
var components = CreateComponents(componentType, instance, designerHost);
InitializeComponents(components, designerHost);
Control rootControl = designerHost.RootComponent as Control;
Control parent = rootControl.Parent;
ISite site = rootControl.Site;
// copy instance properties to root control.
CopyProperties(instance, designerHost.RootComponent);
rootControl.AllowDrop = true;
rootControl.Parent = parent;
rootControl.Visible = true;
rootControl.Site = site;
designerHost.RootComponent.Site.Name = instance.Name;
return surface;
}
开发者ID:die-Deutsche-Orthopaedie,项目名称:LiteDevelop,代码行数:40,代码来源:DesignerCodeReader.cs
示例16: PluginManager
/// <summary>
/// Initializes a new instance of the <see cref="PluginManager"/> class.
/// </summary>
/// <param name="serviceContainer">The service container.</param>
public PluginManager(IServiceContainer serviceContainer)
{
if (serviceContainer == null) throw new ArgumentNullException("serviceContainer");
services = serviceContainer;
settingsService = services.GetService<ISettingsService>(true);
}
开发者ID:odalet,项目名称:CITray,代码行数:11,代码来源:PluginManager.cs
示例17: LightInjectResolver
public LightInjectResolver(IServiceContainer container)
{
if (container == null)
throw new ArgumentNullException("Container cannot be null");
this.container = container;
}
开发者ID:napalm684,项目名称:ReciPiBook,代码行数:7,代码来源:LightInjectResolver.cs
示例18: HttpServiceCaller
/// <summary>
/// HttpServiceCaller初始化
/// </summary>
/// <param name="group"></param>
/// <param name="config"></param>
/// <param name="container"></param>
public HttpServiceCaller(IWorkItemsGroup group, CastleServiceConfiguration config, IServiceContainer container)
{
this.config = config;
this.container = container;
this.smart = group;
this.callers = new HttpCallerInfoCollection();
this.callTimeouts = new Dictionary<string, int>();
}
开发者ID:rajayaseelan,项目名称:mysoftsolution,代码行数:14,代码来源:HttpServiceCaller.cs
示例19: MainFormInteractor
public MainFormInteractor(IServiceProvider services)
{
this.dlgFactory = services.RequireService<IDialogFactory>();
this.mru = new MruList(MaxMruItems);
this.mru.Load(MruListFile);
this.sc = services.RequireService<IServiceContainer>();
this.nextPage = new Dictionary<IPhasePageInteractor, IPhasePageInteractor>();
}
开发者ID:gh0std4ncer,项目名称:reko,代码行数:8,代码来源:MainFormInteractor.cs
示例20: AddComponentsTo
public static void AddComponentsTo(IServiceContainer container)
{
AddGenericRepositoriesTo(container);
AddCustomRepositoriesTo(container);
AddApplicationServicesTo(container);
container.AddService(typeof(IValidator), typeof(Validator), LinFu.IoC.Configuration.LifecycleType.OncePerRequest);
}
开发者ID:sztupy,项目名称:CodeChirp,代码行数:8,代码来源:ComponentRegistrar.cs
注:本文中的IServiceContainer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论