/// <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);
		}
		/// <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 proxyBehaviorAttribute = ReadProxyBehaviorFromType(model.Implementation);
			if (proxyBehaviorAttribute == null)
			{
				proxyBehaviorAttribute = new ComponentProxyBehaviorAttribute();
			}

			ReadProxyBehaviorFromConfig(model, proxyBehaviorAttribute);

			ApplyProxyBehavior(proxyBehaviorAttribute, model);
		}
		/// <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);
		}
		/// <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);
		}
		/// <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);
		}
		private void ReadProxyBehaviorFromConfig(ComponentModel model, ComponentProxyBehaviorAttribute behavior)
		{
			if (model.Configuration == null)
			{
				return;
			}
#if !SILVERLIGHT
			var mbrProxy = model.Configuration.Attributes["marshalByRefProxy"];
			if (mbrProxy != null)
			{
				behavior.UseMarshalByRefProxy = converter.PerformConversion<bool?>(mbrProxy).GetValueOrDefault(false);
			}
#endif
			var interfaces = model.Configuration.Children["additionalInterfaces"];
			if (interfaces == null)
			{
				return;
			}
			var list = new List<Type>(behavior.AdditionalInterfaces);
			foreach (var node in interfaces.Children)
			{
				var interfaceTypeName = node.Attributes["interface"];
				var @interface = converter.PerformConversion<Type>(interfaceTypeName);
				list.Add(@interface);
			}
			behavior.AdditionalInterfaces = list.ToArray();
		}
		private static void ApplyProxyBehavior(ComponentProxyBehaviorAttribute behavior, ComponentModel model)
		{
			var options = ProxyUtil.ObtainProxyOptions(model, true);
#if !SILVERLIGHT
			if (behavior.UseMarshalByRefProxy)
			{
				EnsureComponentRegisteredWithInterface(model);
			}
			options.UseMarshalByRefAsBaseClass = behavior.UseMarshalByRefProxy;
#endif
			options.AddAdditionalInterfaces(behavior.AdditionalInterfaces);
		}
		private static void ApplyProxyBehavior(ComponentProxyBehaviorAttribute behavior, ComponentModel model)
		{
#pragma warning disable 0618 //call to obsolete method
			if (behavior.UseSingleInterfaceProxy
#if (!SILVERLIGHT)
				|| behavior.UseMarshalByRefProxy
#endif
				)
			{
				EnsureComponentRegisteredWithInterface(model);
			}

			ProxyOptions options = ProxyUtil.ObtainProxyOptions(model, true);

			options.UseSingleInterfaceProxy = behavior.UseSingleInterfaceProxy;
#if (!SILVERLIGHT)
			options.UseMarshalByRefAsBaseClass = behavior.UseMarshalByRefProxy;
#endif
			options.AddAdditionalInterfaces(behavior.AdditionalInterfaces);
#pragma warning restore
		}
		private static void ApplyProxyBehavior(ComponentProxyBehaviorAttribute behavior, ComponentModel model)
		{
			var options = model.ObtainProxyOptions();
#if !SILVERLIGHT
			if (behavior.UseMarshalByRefProxy)
			{
				EnsureComponentRegisteredWithInterface(model);
			}
			options.UseMarshalByRefAsBaseClass = behavior.UseMarshalByRefProxy;
#endif
			options.AddAdditionalInterfaces(behavior.AdditionalInterfaces);
			if(model.Implementation.IsInterface)
			{
				options.OmitTarget = true;
			}
		}
		private static void ApplyProxyBehavior(ComponentProxyBehaviorAttribute behavior, ComponentModel model)
		{
			if (behavior.UseSingleInterfaceProxy || behavior.UseMarshalByRefProxy)
			{
				EnsureComponentRegisteredWithInterface(model);
			}

			ProxyOptions options = ProxyUtil.ObtainProxyOptions(model, true);

			options.UseSingleInterfaceProxy = behavior.UseSingleInterfaceProxy;
			options.AddAdditionalInterfaces(behavior.AdditionalInterfaces);
		}