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


C# IKernel.GetSubSystem方法代码示例

本文整理汇总了C#中IKernel.GetSubSystem方法的典型用法代码示例。如果您正苦于以下问题:C# IKernel.GetSubSystem方法的具体用法?C# IKernel.GetSubSystem怎么用?C# IKernel.GetSubSystem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IKernel的用法示例。


在下文中一共展示了IKernel.GetSubSystem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RelativePathSubDependencyResolver

 /// <summary>
 ///   Constructor
 /// </summary>
 public RelativePathSubDependencyResolver(IKernel kernel)
 {
     m_converter = (IConversionManager)kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);
       SettingsSubSystem settingsSubSystem = kernel.GetSettingsSubSystem();
       settingsSubSystem.ResolveRelativePaths = true;
       VALUES = new Dictionary<string, object>();
 }
开发者ID:monemihir,项目名称:castle-windsor-extensions,代码行数:10,代码来源:RelativePathSubDependencyResolver.cs

示例2: KernelDebuggerProxy

		public KernelDebuggerProxy(IKernel kernel)
		{
			if (kernel == null)
			{
				throw new ArgumentNullException("kernel");
			}
			extensions = (IEnumerable<IContainerDebuggerExtension>)(kernel.GetSubSystem(SubSystemConstants.DiagnosticsKey) as IContainerDebuggerExtensionHost) ??
			             new IContainerDebuggerExtension[0];
		}
开发者ID:pil0t,项目名称:Castle.Windsor,代码行数:9,代码来源:KernelDebuggerProxy.cs

示例3: KernelDebuggerProxy

		public KernelDebuggerProxy(IKernel kernel)
		{
			if (kernel == null)
			{
				throw new ArgumentNullException("kernel");
			}
			this.kernel = kernel;
			naming = kernel.GetSubSystem(SubSystemConstants.NamingKey) as INamingSubSystem;
		}
开发者ID:gschuager,项目名称:Castle.Windsor,代码行数:9,代码来源:KernelDebuggerProxy.cs

示例4: GetScopeSubSystem

		private static IScopeManager GetScopeSubSystem(IKernel kernel)
		{
			var scopes = (IScopeManager)kernel.GetSubSystem("scope");
			if (scopes == null)
			{
				throw new InvalidCastException("Unable to obtain the ScopeSubsystem.  " +
				                               "Did you forget to add it using the key 'scope'?");
			}
			return scopes;
		}
开发者ID:pil0t,项目名称:Castle.Windsor,代码行数:10,代码来源:LifestyleExtensions.cs

示例5: ProcessModel

		/// <summary>
		/// Adds the properties as optional dependencies of this component.
		/// </summary>
		/// <param name="kernel"></param>
		/// <param name="model"></param>
		public virtual void ProcessModel(IKernel kernel, ComponentModel model)
		{
			if (converter == null)
			{
				converter = (IConversionManager) 
					kernel.GetSubSystem( SubSystemConstants.ConversionManagerKey );
			}

			InspectProperties(model);
		}
开发者ID:7digital,项目名称:Castle.Windsor,代码行数:15,代码来源:PropertiesDependenciesModelInspector.cs

示例6: Init

		public override void Init(IComponentActivator componentActivator, IKernel kernel, ComponentModel model)
		{
			base.Init(componentActivator, kernel, model);

			manager = kernel.GetSubSystem("scope") as IScopeManager;
			if (manager == null)
			{
				throw new InvalidOperationException("Scope Subsystem not found.  Did you forget to add it?");
			}
		}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:10,代码来源:ScopedLifestyleManager.cs

示例7: ProcessResource

		public override void ProcessResource(IResource source, IConfigurationStore store, IKernel kernel)
		{
			var resourceSubSystem = kernel.GetSubSystem(SubSystemConstants.ResourceKey) as IResourceSubSystem;
			var processor = new XmlProcessor.XmlProcessor(EnvironmentName, resourceSubSystem);

			try
			{
				var element = processor.Process(source);
				var converter = kernel.GetConversionManager();
				Deserialize(element, store, converter);
			}
			catch (XmlProcessorException e)
			{
				throw new ConfigurationProcessingException("Unable to process xml resource.", e);
			}
		}
开发者ID:dohansen,项目名称:Windsor,代码行数:16,代码来源:XmlInterpreter.cs

示例8: ProcessModel

            public virtual void ProcessModel(IKernel kernel, ComponentModel model)
            {
                if (converter == null) {
                    converter = (IConversionManager) kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);
                }

                var targetType = model.Implementation;

                var constructors = targetType.GetConstructors(BindingFlags.Public | BindingFlags.Instance);

                foreach (var constructor in constructors) {
                    // We register each public constructor
                    // and let the ComponentFactory select an
                    // eligible amongst the candidates later
                    model.Constructors.Add(CreateConstructorCandidate(model, constructor));
                }
            }
开发者ID:ruanzx,项目名称:mausch,代码行数:17,代码来源:AttributeServiceOverride.cs

示例9: ProcessModel

		public void ProcessModel(IKernel kernel, ComponentModel model)
		{
			if (model.Configuration != null)
			{
				String manageableProxy = model.Configuration.Attributes["manageableProxy"];

				if (manageableProxy == null) return;

				ITypeConverter converter = (ITypeConverter)
					kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);

				if ((bool)converter.PerformConversion(manageableProxy, typeof (bool)))
				{
//					model.Interceptors.Add();
				}
			}
		}
开发者ID:ralescano,项目名称:castle,代码行数:17,代码来源:ManagementExtensionModelClientInspector.cs

示例10: ReadProxyBehavior

		/// <summary>
		/// Reads the proxy behavior associated with the 
		/// component configuration/type and applies it to the model.
		/// </summary>
		/// <exception cref="System.Configuration.ConfigurationException">
		/// If the conversion fails
		/// </exception>
		/// <param name="kernel"></param>
		/// <param name="model"></param>
		protected virtual void ReadProxyBehavior(IKernel kernel, ComponentModel model)
		{
			ComponentProxyBehaviorAttribute proxyBehaviorAtt = GetProxyBehaviorFromType(model.Implementation);

			if (proxyBehaviorAtt == null)
			{
				proxyBehaviorAtt = new ComponentProxyBehaviorAttribute();
			}

			string useSingleInterfaceProxyAttrib = model.Configuration != null ? model.Configuration.Attributes["useSingleInterfaceProxy"] : null;
			string marshalByRefProxyAttrib = model.Configuration != null ? model.Configuration.Attributes["marshalByRefProxy"] : null;

			ITypeConverter converter = (ITypeConverter)kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);

			if (useSingleInterfaceProxyAttrib != null)
			{
				try
				{
					proxyBehaviorAtt.UseSingleInterfaceProxy = (bool)
						converter.PerformConversion(useSingleInterfaceProxyAttrib, typeof(bool));
				}
				catch(ConverterException ex)
				{
					throw new ConfigurationErrorsException("Could not convert attribute " + 
						"'useSingleInterfaceProxy' to bool. Value is " + useSingleInterfaceProxyAttrib, ex);
				}
			}

			if (marshalByRefProxyAttrib != null)
			{
				try
				{
					proxyBehaviorAtt.UseMarshalByRefProxy = (bool)
						converter.PerformConversion(marshalByRefProxyAttrib, typeof(bool));
				}
				catch(ConverterException ex)
				{
					throw new ConfigurationErrorsException("Could not convert attribute " + 
						"'marshalByRefProxy' to bool. Value is " + marshalByRefProxyAttrib, ex);
				}
			}

			ApplyProxyBehavior(proxyBehaviorAtt, model);
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:53,代码来源:ComponentProxyInspector.cs

示例11: ReadProxyBehavior

		/// <summary>
		/// Reads the proxy behavior associated with the 
		/// component configuration/type and applies it to the model.
		/// </summary>
		/// <exception cref="System.Exception">
		/// If the conversion fails
		/// </exception>
		/// <param name="kernel"></param>
		/// <param name="model"></param>
		protected virtual void ReadProxyBehavior(IKernel kernel, ComponentModel model)
		{
			ComponentProxyBehaviorAttribute proxyBehaviorAtt = GetProxyBehaviorFromType(model.Implementation);

			if (proxyBehaviorAtt == null)
			{
				proxyBehaviorAtt = new ComponentProxyBehaviorAttribute();
			}

			string useSingleInterfaceProxyAttrib = model.Configuration != null ? model.Configuration.Attributes["useSingleInterfaceProxy"] : null;
			
#if !SILVERLIGHT
			string marshalByRefProxyAttrib = model.Configuration != null ? model.Configuration.Attributes["marshalByRefProxy"] : null;
#endif

			ITypeConverter converter = (ITypeConverter)kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);

			if (useSingleInterfaceProxyAttrib != null)
			{
				try
				{
					proxyBehaviorAtt.UseSingleInterfaceProxy = converter.PerformConversion<bool>(useSingleInterfaceProxyAttrib);
				}
				catch(ConverterException ex)
				{
					throw new Exception(string.Format("Could not convert attribute 'useSingleInterfaceProxy' to bool. Value is '{0}'.", useSingleInterfaceProxyAttrib), ex);
				}
			}
#if !SILVERLIGHT
			if (marshalByRefProxyAttrib != null)
			{
				try
				{
					proxyBehaviorAtt.UseMarshalByRefProxy = converter.PerformConversion<bool>(marshalByRefProxyAttrib);
				}
				catch(ConverterException ex)
				{
					throw new Exception(string.Format("Could not convert attribute 'marshalByRefProxy' to bool. Value is '{0}'.", marshalByRefProxyAttrib), ex);
				}
			}
#endif
			ApplyProxyBehavior(proxyBehaviorAtt, model);
		}
开发者ID:HEskandari,项目名称:Castle.InversionOfControl,代码行数:52,代码来源:ComponentProxyInspector.cs

示例12: BuildMap

		private void BuildMap(Dictionary<Type, IHandler> map, IKernel currentKernel)
		{
			var defaults = currentKernel.GetSubSystem(SubSystemConstants.NamingKey) as IExposeDefaultComponentsForServices;
			if (defaults != null)
			{
				foreach (var @default in defaults.GetDefaultComponentsForServices())
				{
					if (map.ContainsKey(@default.Key))
					{
						continue;
					}
					map.Add(@default.Key, @default.Value);
				}
			}
			var parentKernel = currentKernel.Parent;
			if (parentKernel != null)
			{
				BuildMap(map, parentKernel);
			}
		}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:20,代码来源:DefaultComponentPerService.cs

示例13: ConfigureComponentModel

        /// <summary>
        ///   Contribute to component model after standard <see cref="IContributeComponentModelConstruction" /> run.
        /// </summary>
        /// <param name="kernel"></param>
        /// <param name="model"></param>
        public void ConfigureComponentModel(IKernel kernel, ComponentModel model)
        {
            PropertiesSubSystem subsystem = kernel.GetSubSystem<PropertiesSubSystem>(PropertiesSubSystem.SubSystemKey);

              foreach (var prop in m_properties)
              {
            if (!subsystem.Resolver.CanResolve(prop.ConfigPropertyName))
              throw new ConfigurationProcessingException("No config property with name '" + prop.ConfigPropertyName + "' found");

            string propKey = m_implPropertyTypes.Keys.FirstOrDefault(f => f.Equals(prop.Name, StringComparison.OrdinalIgnoreCase));

            if (string.IsNullOrWhiteSpace(propKey))
              throw new ConfigurationProcessingException("No public property with a similar to name '" + prop.Name + "' found on " + model.Implementation.FullName);

            Type propType = m_implPropertyTypes[propKey];

            object value = subsystem.Resolver.GetValue(prop.ConfigPropertyName, propType);

            model.CustomDependencies[propKey] = value;
              }
        }
开发者ID:monemihir,项目名称:castle-windsor-extensions,代码行数:26,代码来源:ResolvablePropertyDescriptor.cs

示例14: IsCacheModelOn

		private bool IsCacheModelOn(IKernel kernel, ComponentModel model)
		{
			IConversionManager converter = kernel.GetSubSystem( SubSystemConstants.ConversionManagerKey ) as IConversionManager;
			bool allowCache = false;

			if (model.Configuration != null)
			{
				String enableInterceptionAttribute = model.Configuration.Attributes["Cache"];
				
				if (enableInterceptionAttribute != null)
				{
					allowCache = (bool) converter.PerformConversion( enableInterceptionAttribute, typeof(bool) );
				}
			}

			if ( model.Implementation.IsDefined( typeof(CacheAttribute), true ) )
			{
				allowCache = true;
			}

			return allowCache;
		}
开发者ID:ralescano,项目名称:castle,代码行数:22,代码来源:CacheComponentInspector.cs

示例15: GetTrackedComponentsDiagnostic

		public static ITrackedComponentsDiagnostic GetTrackedComponentsDiagnostic(IKernel kernel)
		{
			var diagnosticsHost = (IDiagnosticsHost)kernel.GetSubSystem(SubSystemConstants.DiagnosticsKey);
			return diagnosticsHost.GetDiagnostic<ITrackedComponentsDiagnostic>();
		}
开发者ID:spiderjoe02,项目名称:Castle.Windsor,代码行数:5,代码来源:LifecycledComponentsReleasePolicy.cs


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