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