/// <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> /// 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); }