本文整理汇总了C#中IServiceContainer.AddComponentInstance方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceContainer.AddComponentInstance方法的具体用法?C# IServiceContainer.AddComponentInstance怎么用?C# IServiceContainer.AddComponentInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceContainer
的用法示例。
在下文中一共展示了IServiceContainer.AddComponentInstance方法的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: 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));
}
}
示例3: AddComponentInstance
private void AddComponentInstance(IServiceContainer container, object instance)
{
container.AddComponentInstance(instance.GetType().FullName, instance.GetType(), instance);
}
示例4: InitializeUrlParser
private void InitializeUrlParser(IServiceContainer container)
{
var config = container.Resolve<HostSection>();
IUrlParser parser;
if (config.MultipleSites)
parser = new MultipleSitesParser(container.Resolve<IPersister>(), container.Resolve<IWebContext>(), container.Resolve<IHost>(), container.Resolve<Plugin.ConnectionMonitor>(), config);
else
parser = new UrlParser(container.Resolve<IPersister>(), container.Resolve<IWebContext>(), container.Resolve<IHost>(), container.Resolve<Plugin.ConnectionMonitor>(), config);
if (config.Web.Urls.EnableCaching)
parser = new CachingUrlParserDecorator(parser, container.Resolve<IPersister>(), container.Resolve<IWebContext>(), container.Resolve<CacheWrapper>());
container.AddComponentInstance("n2.urlParser", typeof(IUrlParser), parser);
}