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


C# IServiceContainer.AddComponent方法代码示例

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

示例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);
		}
开发者ID:navneetccna,项目名称:n2cms,代码行数:7,代码来源:ContainerConfigurer.cs

示例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));
            }
        }
开发者ID:joaohortencio,项目名称:n2cms,代码行数:21,代码来源:ContainerConfigurer.cs

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


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