2014年7月15日星期二

Loading System.ServiceModel configuration section using ConfigurationManager



// Automagically find all client endpoints defined in app.config
ClientSection clientSection = 
    ConfigurationManager.GetSection("system.serviceModel/client") as ClientSection;

ChannelEndpointElementCollection endpointCollection =
    clientSection.ElementInformation.Properties[string.Empty].Value as     ChannelEndpointElementCollection;
List endpointNames = new List();
foreach (ChannelEndpointElement endpointElement in endpointCollection)
{
    endpointNames.Add(endpointElement.Name);
}
// use endpointNames somehow ...

http://mostlytech.blogspot.com/2007/11/programmatically-enumerate-wcf.html

没有评论:

发表评论

序言