/// <summary> /// Get Binding /// </summary> /// <param name="bindingName"></param> /// <param name="configName"></param> /// <returns></returns> public static Binding GetBinding(this string bindingName, string configName) { Binding loBinding = null; IBindingConfigurationElement loBindingConfigElement = null; var loBindingsSection = moGetBindingsSection(configName); if (loBindingsSection == null) { return(loBinding); } foreach (var loElement in loBindingsSection.BindingCollections.Where(r => r.ConfiguredBindings.Count > 0)) { loBindingConfigElement = loElement.ConfiguredBindings.FirstOrDefault(r => r.Name == bindingName); if (loBindingConfigElement != null) { loBinding = Activator.CreateInstance(loElement.BindingType) as Binding; loBinding.Name = bindingName; loBindingConfigElement.ApplyConfiguration(loBinding); break; } } return(loBinding); }
private Binding method_0(string string_1, ServiceModelSectionGroup serviceModelSectionGroup_0) { BindingCollectionElement bindingCollectionElement = serviceModelSectionGroup_0.Bindings[string_1]; Binding result; if (bindingCollectionElement.ConfiguredBindings.Count > 0) { IBindingConfigurationElement bindingConfigurationElement = bindingCollectionElement.ConfiguredBindings[0]; Binding binding = this.method_1(bindingConfigurationElement); if (bindingConfigurationElement != null) { bindingConfigurationElement.ApplyConfiguration(binding); } if (this.nullable_0.HasValue) { binding.CloseTimeout = this.nullable_0.Value; binding.OpenTimeout = this.nullable_0.Value; binding.ReceiveTimeout = this.nullable_0.Value; binding.SendTimeout = this.nullable_0.Value; } result = binding; } else { result = null; } return(result); }
private Binding GetBinding(IBindingConfigurationElement bindingElement) { Type type = bindingElement.GetType(); Binding binding = null; if (type == typeof(BasicHttpBindingElement)) { binding = new BasicHttpBinding(); } if (type == typeof(WSHttpBindingElement)) { binding = new WSHttpBinding(); } if (type == typeof(NetTcpBindingElement)) { binding = new NetTcpBinding(); } if (type == typeof(NetNamedPipeBindingElement)) { binding = new NetNamedPipeBinding(); } //bug... bindingElement.ApplyConfiguration(binding); return(binding); }
private Binding CreateBinding(string bindingName, ServiceModelSectionGroup group) { BindingCollectionElement bindingCollectionElement = group.Bindings[bindingName]; if (bindingCollectionElement.ConfiguredBindings.Count > 0) { IBindingConfigurationElement bindingConfigurationElement = bindingCollectionElement.ConfiguredBindings[0]; Binding binding = this.GetBinding(bindingConfigurationElement); if (bindingConfigurationElement != null) { bindingConfigurationElement.ApplyConfiguration(binding); } return(binding); } return(null); }
/// <summary> /// Configures the binding for the selected endpoint /// </summary> /// <param name="bindingName"></param> /// <param name="group"></param> /// <returns></returns> protected virtual Binding CreateBinding(string bindingName, ServiceModelSectionGroup group) { BindingCollectionElement bindingElementCollection = group.Bindings[bindingName]; if (bindingElementCollection.ConfiguredBindings.Count > 0) { IBindingConfigurationElement be = bindingElementCollection.ConfiguredBindings[0]; Binding binding = GetBinding(be); if (be != null) { be.ApplyConfiguration(binding); } return(binding); } return(null); }
private Binding LookupBinding(ServiceModelSectionGroup group, string bindingName, string configurationName) { BindingCollectionElement bindingElementCollection = group.Bindings[bindingName]; if (bindingElementCollection.ConfiguredBindings.Count == 0) { return(null); } IBindingConfigurationElement bindingConfigurationElement = bindingElementCollection.ConfiguredBindings.First(item => item.Name == configurationName); Binding binding = GetBinding(bindingConfigurationElement); if (bindingConfigurationElement != null) { bindingConfigurationElement.ApplyConfiguration(binding); } return(binding); }
public static Binding CreateBinding( string bindingSectionName, string bindingName, ServiceModelSectionGroup serviceModelSection) { Binding binding = null; BindingCollectionElement bindingElementCollection = serviceModelSection.Bindings[bindingSectionName]; IBindingConfigurationElement bindingElement = bindingElementCollection.ConfiguredBindings.First(be => StringUtil.CompareIgnoreCase(be.Name, bindingName)); if (bindingElement != null) { binding = GetBinding(bindingElement); bindingElement.ApplyConfiguration(binding); } return(binding); }
private Binding CreateBinding( string bindingName, ServiceModelSectionGroup group) { BindingCollectionElement bindingCollectionElem = group.Bindings[bindingName]; if (bindingCollectionElem.ConfiguredBindings.Count == 0) { return(null); } IBindingConfigurationElement bindingElem = bindingCollectionElem.ConfiguredBindings[0]; var binding = GetBinding(bindingElem); if (bindingElem != null && binding != null) { bindingElem.ApplyConfiguration(binding); } return(binding); }
/// <summary> /// Configures the binding for the selected endpoint /// </summary> /// <param name="bindingName"></param> /// <param name="bindingSection"></param> /// <param name="group"></param> /// <returns></returns> private Binding CreateBinding(string bindingName, string bindingSection, ServiceModelSectionGroup group) { BindingCollectionElement bindingElementCollection = group.Bindings[bindingName]; if (bindingElementCollection.ConfiguredBindings.Count > 0) { IBindingConfigurationElement be = bindingElementCollection.ConfiguredBindings.Single(b => b.Name.Equals(bindingSection)); Binding binding = GetBinding(be); if (be != null) { be.ApplyConfiguration(binding); } return(binding); } return(null); }
/// <summary> /// 为所选择的终结点配置绑定 /// </summary> /// <param name="bindingName"></param> /// <param name="group"></param> /// <returns></returns> private Binding CreateBinding(string bindingName, ServiceModelSectionGroup group) { BindingCollectionElement bindingElementCollection = group.Bindings[bindingName]; if (bindingElementCollection.ConfiguredBindings.Count > 0) { IBindingConfigurationElement be = bindingElementCollection.ConfiguredBindings[0]; Binding binding = GetBinding(be); if (be != null) { be.ApplyConfiguration(binding); } if (_timeout != null) { binding.CloseTimeout = (TimeSpan)_timeout; binding.OpenTimeout = (TimeSpan)_timeout; binding.ReceiveTimeout = (TimeSpan)_timeout; binding.SendTimeout = (TimeSpan)_timeout; } return(binding); } return(null); }
/// <summary> /// 获取绑定信息 /// </summary> /// <param name="bindingName">绑定名</param> /// <param name="configName">配置名</param> /// <returns></returns> public static Binding GetBinding(string bindingName, string configName) { Binding binding = null; IBindingConfigurationElement bindingConfigurationElement = null; var bindingsSection = GetBindingsSection(configName); if (bindingsSection == null) { return(null); } foreach (BindingCollectionElement element in bindingsSection.BindingCollections.Where(x => x.ConfiguredBindings.Count > 0)) { bindingConfigurationElement = element.ConfiguredBindings.FirstOrDefault(x => x.Name == bindingName); if (bindingConfigurationElement != null) { binding = Activator.CreateInstance(element.BindingType) as Binding; binding.Name = bindingName; bindingConfigurationElement.ApplyConfiguration(binding); break; } } return(binding); }
private static Binding CreateBinding(IBindingConfigurationElement b, BindingCollectionElement be) { var binding = (Binding)Activator.CreateInstance(be.BindingType); b.ApplyConfiguration(binding); binding.Name = b.Name; return binding; }