/// <summary>
 ///
 /// </summary>
 /// <param name="channelProxy"></param>
 private void SetDefaultValues(object channelProxy)
 {
     if (ProductTemplate == null || !ProductTemplate.PropertyValues.Contains(ChannelManagerPropertyName))
     {
         Type        channelManagerType      = null;
         Type        channelType             = WcfChannelProxyTypeBuilder.FindChannelType(channelProxy.GetType());
         List <Type> contructorArgumentTypes = new List <Type>();
         contructorArgumentTypes.Add(typeof(string));
         List <object> constructorArguments = new List <object>();
         constructorArguments.Add(EndpointConfigurationName);
         if (string.IsNullOrEmpty(ChannelManagementMode) || ChannelManagementMode.Equals(SingleAction))
         {
             channelManagerType = typeof(SingleActionChannelManager <>).MakeGenericType(channelType);
         }
         else
         {
             channelManagerType = typeof(ChannelPoolManager <>).MakeGenericType(channelType);
             contructorArgumentTypes.Add(typeof(IPoolFactory));
             if (ChannelManagementMode.Equals(FixedPool))
             {
                 constructorArguments.Add(new SimplePoolFactory());
             }
             else
             {
                 constructorArguments.Add(new AutoSizePoolFactory());
             }
         }
         ConstructorInfo managerConstructor = channelManagerType.GetConstructor(contructorArgumentTypes.ToArray());
         object          channelManager     = ObjectUtils.InstantiateType(managerConstructor, constructorArguments.ToArray());
         PropertyInfo    property           = channelProxy.GetType().GetProperty(ChannelManagerPropertyName);
         property.SetValue(channelProxy, channelManager, null);
     }
 }
        /// <summary>
        /// Generates a subclass of the specified ChannelActionWrapperType and the ChannelType.
        /// </summary>
        protected virtual void GenerateProxy()
        {
            Type baseClass            = BuildChannelActionWrapperType();
            IProxyTypeBuilder builder = new WcfChannelProxyTypeBuilder(baseClass);
            Type wrapper = builder.BuildProxyType();

            proxyConstructor = wrapper.GetConstructor(Type.EmptyTypes);
        }
 /// <summary>
 /// Validates the configuration.
 /// </summary>
 public virtual void AfterPropertiesSet()
 {
     if ((ChannelType == null && ChannelActionWrapperType == null) ||
         (ChannelType == null && ChannelActionWrapperType != null && WcfChannelProxyTypeBuilder.FindChannelType(ChannelActionWrapperType).IsGenericParameter))
     {
         throw new ArgumentException("No channeltype supplied.");
     }
     if (string.IsNullOrEmpty(EndpointConfigurationName))
     {
         throw new ArgumentException("No endpoint supplied.");
     }
 }
        /// <summary>
        /// Returns the channel type.
        /// </summary>
        /// <param name="channelActionWrapperType">The channelActionWrapperType being used.</param>
        /// <returns>The channel type.</returns>
        protected virtual Type BuildChannelType(Type channelActionWrapperType)
        {
            Type channelType = null;

            if (ChannelType != null)
            {
                channelType = ChannelType;
            }
            else
            {
                channelType = WcfChannelProxyTypeBuilder.FindChannelType(channelActionWrapperType);
            }
            return(channelType);
        }
 /// <summary>
 /// Generates a subclass of the specified ChannelActionWrapperType and the ChannelType.
 /// </summary>
 protected virtual void GenerateProxy()
 {
     Type baseClass = BuildChannelActionWrapperType();
     IProxyTypeBuilder builder = new WcfChannelProxyTypeBuilder(baseClass);
     Type wrapper = builder.BuildProxyType();
     proxyConstructor = wrapper.GetConstructor(Type.EmptyTypes);
 }