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


C# IKernel.GetConversionManager方法代码示例

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


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

示例1: 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

			var converter = kernel.GetConversionManager();
			if (useSingleInterfaceProxyAttrib != null)
			{
#pragma warning disable 0618 //call to obsolete method
				proxyBehaviorAtt.UseSingleInterfaceProxy =
					converter.PerformConversion<bool?>(useSingleInterfaceProxyAttrib).GetValueOrDefault(false);
#pragma warning restore
			}
#if !SILVERLIGHT
			if (marshalByRefProxyAttrib != null)
			{
				proxyBehaviorAtt.UseMarshalByRefProxy =
					converter.PerformConversion<bool?>(marshalByRefProxyAttrib).GetValueOrDefault(false);
			}
#endif
			ApplyProxyBehavior(proxyBehaviorAtt, model);
		}
开发者ID:aledeniz,项目名称:Castle.Windsor,代码行数:41,代码来源:ComponentProxyInspector.cs

示例2: EnsureConverterInitialized

		private void EnsureConverterInitialized(IKernel kernel)
		{
			if(converter == null)
			{
				converter = kernel.GetConversionManager();
			}
		}
开发者ID:HEskandari,项目名称:Castle.InversionOfControl,代码行数:7,代码来源:ComponentActivatorInspector.cs

示例3: 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

示例4: ProcessModel

		public virtual void ProcessModel(IKernel kernel, ComponentModel model)
		{
			if (converter == null)
			{
				converter = kernel.GetConversionManager();
			}

			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:vbedegi,项目名称:Castle.InversionOfControl,代码行数:19,代码来源:ConstructorDependenciesModelInspector.cs

示例5: ProcessModel

		public void ProcessModel(IKernel kernel, ComponentModel model)
		{
			if (model.Configuration == null) return;

			var interfaces = model.Configuration.Children["additionalInterfaces"];
			if (interfaces == null) return;

			if(converter == null)
			{
				converter = kernel.GetConversionManager();
			}
			var list = new List<Type>();
			foreach (var @interface in interfaces.Children
				.Where(c => c.Name.Equals("add", StringComparison.InvariantCultureIgnoreCase)))
			{
				var interfaceTypeName = @interface.Attributes["interface"];
				list.Add(converter.PerformConversion<Type>(interfaceTypeName));
			}

			var options = ProxyUtil.ObtainProxyOptions(model, true);
			options.AddAdditionalInterfaces(list.ToArray());
		}
开发者ID:vbedegi,项目名称:Castle.InversionOfControl,代码行数:22,代码来源:AdditionalInterfacesInspector.cs

示例6: 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)
		{
			var proxyBehaviorAtt = GetProxyBehaviorFromType(model.Implementation);

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

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

			var converter = kernel.GetConversionManager();
#if !SILVERLIGHT
			if (marshalByRefProxyAttrib != null)
			{
				proxyBehaviorAtt.UseMarshalByRefProxy =
					converter.PerformConversion<bool?>(marshalByRefProxyAttrib).GetValueOrDefault(false);
			}
#endif
			ApplyProxyBehavior(proxyBehaviorAtt, model);
		}
开发者ID:7digital,项目名称:Castle.Windsor,代码行数:32,代码来源:ComponentProxyInspector.cs

示例7: ProcessResource

        /// <summary>
        ///   Should obtain the contents from the resource,
        ///   interpret it and populate the <see cref="T:Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore" />
        ///   accordingly.
        /// </summary>
        /// <param name="resource"></param>
        /// <param name="store"></param>
        /// <param name="kernel"></param>
        public override void ProcessResource(IResource resource, IConfigurationStore store, IKernel kernel)
        {
            PropertiesJsonProcessor processor = new PropertiesJsonProcessor();
              processor.Process(resource);

              IConversionManager converter = kernel.GetConversionManager();

              // setup the properties resolver
              Resolver = new PropertyResolver(processor, converter);
              m_processResourceCalled = true;
        }
开发者ID:monemihir,项目名称:castle-windsor-extensions,代码行数:19,代码来源:JsonPropertiesInterpreter.cs

示例8: Initialize

		/// <summary>
		///   Initializes this instance with the specified dependency delegate.
		/// </summary>
		/// <param name="kernel">kernel</param>
		/// <param name = "dependencyDelegate">The dependency delegate.</param>
		public void Initialize(IKernel kernel, DependencyDelegate dependencyDelegate)
		{
			this.kernel = kernel;
			converter = kernel.GetConversionManager();
			dependencyResolvingDelegate = dependencyDelegate;
		}
开发者ID:corruptmem,项目名称:Castle.Windsor,代码行数:11,代码来源:DefaultDependencyResolver.cs

示例9: ObtainProxyHook

		private static IReference<IProxyGenerationHook> ObtainProxyHook(IKernel kernel, IConfiguration config)
		{
			IProxyGenerationHook hook = null;

			if (config != null)
			{
				var hookAttrib = config.Attributes[Constants.ControlProxyHookAttrib];

				if (hookAttrib != null)
				{
					if (ReferenceExpressionUtil.IsReference(hookAttrib))
					{
						var hookKey = ReferenceExpressionUtil.ExtractComponentKey(hookAttrib);
						return new ComponentReference<IProxyGenerationHook>(hookKey);
					}

					var converter = kernel.GetConversionManager();
					var hookType = converter.PerformConversion<Type>(hookAttrib);

					if (hookType.Is<IProxyGenerationHook>() == false)
					{
						var message = String.Format("The specified controlProxyHook does " +
						                            "not implement the interface {1}. Type {0}",
						                            hookType.FullName, typeof(IProxyGenerationHook).Name);

						throw new ConfigurationErrorsException(message);
					}

					hook = (IProxyGenerationHook)Activator.CreateInstance(hookType);
				}
			}

			if (hook == null)
			{
				hook = SynchronizeProxyHook.Instance;
			}

			return new InstanceReference<IProxyGenerationHook>(hook);
		}
开发者ID:vbedegi,项目名称:Castle.InversionOfControl,代码行数:39,代码来源:CreateOnUIThreadInspector.cs

示例10: ProcessResource

        /// <summary>
        ///   Should obtain the contents from the resource,
        ///   interpret it and populate the <see cref="IConfigurationStore" />
        ///   accordingly.
        /// </summary>
        /// <param name="resource">Resource to process</param>
        /// <param name="store">Windsor configuration store</param>
        /// <param name="kernel">Windsor kernel</param>
        public override void ProcessResource(IResource resource, IConfigurationStore store, IKernel kernel)
        {
            var resourceSubSystem = kernel.GetSubSystem(SubSystemConstants.ResourceKey) as IResourceSubSystem;

              PropertiesXmlProcessor processor = new PropertiesXmlProcessor(EnvironmentName, resourceSubSystem);

              IConversionManager converter = kernel.GetConversionManager();
              processor.Process(resource);

              // setup the properties resolver
              m_resolver = new PropertyResolver(processor, converter);
              m_processResourceCalled = true;
        }
开发者ID:monemihir,项目名称:castle-windsor-extensions,代码行数:21,代码来源:PropertiesInterpreter.cs


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