Пример #1
0
        private void ApplyConfiguration(string configurationName)
        {
            BindingsSection bindings = ((BindingsSection)(ConfigurationManager.GetSection("system.serviceModel/bindings")));
            NetHttpBindingCollectionElement section = (NetHttpBindingCollectionElement)bindings["netHttpBinding"];
            NetHttpBindingElement           element = section.Bindings[configurationName];

            if ((element == null))
            {
                throw new System.Configuration.ConfigurationErrorsException(string.Format(CultureInfo.CurrentCulture, "There is no binding named {0} at {1}.", configurationName, section.BindingName));
            }
            else
            {
                element.ApplyConfiguration(this);
            }
        }
        void ApplyConfiguration(string configurationName)
        {
            NetHttpBindingCollectionElement section = NetHttpBindingCollectionElement.GetBindingCollectionElement();
            NetHttpBindingElement           element = section.Bindings[configurationName];

            if (element == null)
            {
                throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR.GetString(
                                                                                     SR.ConfigInvalidBindingConfigurationName,
                                                                                     configurationName,
                                                                                     ConfigurationStrings.NetHttpBindingCollectionElementName)));
            }
            else
            {
                element.ApplyConfiguration(this);
            }
        }