本文整理汇总了C#中IServiceContainer.AddComponent方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceContainer.AddComponent方法的具体用法?C# IServiceContainer.AddComponent怎么用?C# IServiceContainer.AddComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceContainer
的用法示例。
在下文中一共展示了IServiceContainer.AddComponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: 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);
}
示例3: InitializeEnvironment
protected virtual void InitializeEnvironment(IServiceContainer container, HostSection hostConfig)
{
if (hostConfig != null)
{
Url.DefaultExtension = hostConfig.Web.Extension;
PathData.PageQueryKey = hostConfig.Web.PageQueryKey;
PathData.ItemQueryKey = hostConfig.Web.ItemQueryKey;
PathData.PartQueryKey = hostConfig.Web.PartQueryKey;
if (!hostConfig.Web.IsWeb)
container.AddComponentInstance("n2.webContext.notWeb", typeof(IWebContext), new ThreadContext());
if (hostConfig.Web.Urls.EnableCaching)
container.AddComponent("n2.web.cachingUrlParser", typeof(IUrlParser), typeof(CachingUrlParserDecorator));
if (hostConfig.MultipleSites)
container.AddComponent("n2.multipleSitesParser", typeof(IUrlParser), typeof(MultipleSitesParser));
else
container.AddComponent("n2.urlParser", typeof(IUrlParser), typeof(UrlParser));
}
}
示例4: 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());
}
}
}