private void ApplyConfiguration(string configurationName) { BasicHttpBindingElement element2 = BasicHttpBindingCollectionElement.GetBindingCollectionElement().Bindings[configurationName]; if (element2 == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(System.ServiceModel.SR.GetString("ConfigInvalidBindingConfigurationName", new object[] { configurationName, "basicHttpBinding" }))); } element2.ApplyConfiguration(this); }
public void BasicHttpBinding() { ServiceModelSectionGroup config = (ServiceModelSectionGroup)ConfigurationManager.OpenExeConfiguration("Test/config/basicHttpBinding").GetSectionGroup("system.serviceModel"); BasicHttpBindingCollectionElement basicHttpBinding = config.Bindings.BasicHttpBinding; Assert.AreEqual(2, basicHttpBinding.Bindings.Count, "count"); BasicHttpBindingElement binding = basicHttpBinding.Bindings [0]; Assert.AreEqual("BasicHttpBinding_Service", binding.Name, "Name"); Assert.AreEqual(Encoding.UTF8, binding.TextEncoding, "Name"); Assert.AreEqual(SecurityAlgorithmSuite.Default, binding.Security.Message.AlgorithmSuite, "Name"); }
void ApplyConfiguration(string configurationName) { BasicHttpBindingCollectionElement section = BasicHttpBindingCollectionElement.GetBindingCollectionElement(); BasicHttpBindingElement element = section.Bindings[configurationName]; if (element == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException( SR.GetString(SR.ConfigInvalidBindingConfigurationName, configurationName, ConfigurationStrings.BasicHttpBindingCollectionElementName))); } else { element.ApplyConfiguration(this); } }
static BindingCollectionElement CreateCollectionElement( string bindingName, IBindingConfigurationElement element) { switch (bindingName) { case "basicHttpBinding": { var http = new BasicHttpBindingCollectionElement (); http.Bindings.Add ((BasicHttpBindingElement)element); return http; } #if NET_4_5 case "basicHttpsBinding": { var https = new BasicHttpsBindingCollectionElement (); https.Bindings.Add ((BasicHttpsBindingElement)element); return https; } #endif case "netTcpBinding": { var netTcp = new NetTcpBindingCollectionElement (); netTcp.Bindings.Add ((NetTcpBindingElement)element); return netTcp; } case "customBinding": { var custom = new CustomBindingCollectionElement (); custom.Bindings.Add ((CustomBindingElement)element); return custom; } default: throw new InvalidOperationException (); } }