internal ConfigWriter(System.Configuration.Configuration configuration) { this.bindingsSection = BindingsSection.GetSection(configuration); ServiceModelSectionGroup sectionGroup = ServiceModelSectionGroup.GetSectionGroup(configuration); this.channels = sectionGroup.Client.Endpoints; this.config = configuration; }
public static Binding GetFromConfig(string configurationName) { var bingingsSection = BindingsSection.GetSection(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)); var bindingType = (from b in bingingsSection.BindingCollections where b.ConfiguredBindings.Count > 0 && b.ContainsKey(configurationName) select b.BindingType).FirstOrDefault(); var binding = bindingType != null?Activator.CreateInstance(bindingType, configurationName) : null; return((Binding)binding); }
static void Main(string[] args) { var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var bingingsSection = BindingsSection.GetSection(config); string netTcpSource = bingingsSection.NetTcpBinding.ElementInformation.Source; string basicHttpSource = bingingsSection.BasicHttpBinding.ElementInformation.Source; Console.WriteLine("Net TCP Binding came from \"{0}\"", netTcpSource); Console.WriteLine("Basic HTTP Binding came from \"{0}\"", basicHttpSource); }
internal ConfigWriter(Configuration configuration) { this.bindingTable = new Dictionary <Binding, BindingDictionaryValue>(); this.bindingsSection = BindingsSection.GetSection(configuration); ServiceModelSectionGroup serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(configuration); this.channels = serviceModelSectionGroup.Client.Endpoints; this.config = configuration; }