private static EndpointAndAddressConfiguration ReadServiceConfiguration(string configurationNameBase) { var configurationFileName = $"{configurationNameBase}.config"; // Use xml reading instead of ConfigurationManager as there are no appropriate classes of ConfigurationSection available. var document = new XmlDocument(); document.Load(configurationFileName); // Read limited part of the current configuration in file. var endpointNode = document.DocumentElement.SelectSingleNode("/configuration/system.serviceModel/client/endpoint"); var endpointAttributes = endpointNode.Attributes; var serviceConfiguration = new EndpointAndAddressConfiguration( Enum.Parse <EndpointConfiguration>(endpointAttributes["bindingConfiguration"].Value), endpointAttributes["address"].Value); return(serviceConfiguration); }
// Intended to enable injection. // TODO Maybe the constructor with Binding could be applied instead with more options. public ProductsServiceClient(EndpointAndAddressConfiguration configuration) : this(configuration.EndpointConfiguration, configuration.RemoteAddress) { }