private WebHttpBinding CreateBindingFromConfig() { ServiceModelSectionGroup config = (ServiceModelSectionGroup)ConfigurationManager.OpenExeConfiguration("Test/config/webHttpBinding").GetSectionGroup("system.serviceModel"); WebHttpBindingCollectionElement collectionElement = (WebHttpBindingCollectionElement)config.Bindings ["webHttpBinding"]; WebHttpBindingElement el = collectionElement.Bindings ["WebHttpBinding1_Service"]; WebHttpBinding b = new WebHttpBinding(); el.ApplyConfiguration(b); return(b); }
void ApplyConfiguration(string configurationName) { WebHttpBindingCollectionElement section = WebHttpBindingCollectionElement.GetBindingCollectionElement(); WebHttpBindingElement element = section.Bindings[configurationName]; if (element == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException( SR2.GetString(SR2.ConfigInvalidBindingConfigurationName, configurationName, WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName))); } else { element.ApplyConfiguration(this); } }
public WebHttpBinding(string configurationName) { #if !NET_2_1 && !XAMMAC_4_5 BindingsSection bindingsSection = ConfigUtil.BindingsSection; WebHttpBindingElement el = (WebHttpBindingElement)bindingsSection ["webHttpBinding"].ConfiguredBindings.FirstOrDefault(c => c.Name == configurationName); if (el != null) { Initialize(el.Security.Mode); // to initialize Transport correctly. el.ApplyConfiguration(this); } else if (!String.IsNullOrEmpty(configurationName)) { throw new ConfigurationException(String.Format("Specified webHttpBinding configuration '{0}' was not found", configurationName)); } else { Initialize(WebHttpSecurityMode.None); } #else Initialize(WebHttpSecurityMode.None); #endif }