public void Load() { var clientSection = ConfigurationManager.GetSection(@"system.serviceModel\client") as ClientSection; if (clientSection == null) return; this.client = clientSection; this.knownServices = WcfClientEndpointExplorer.GetKnownServices(clientSection).ToArray(); }
private static IEnumerable<IWcfService> GetKnownServices(ClientSection client) { if (client == null) yield break; foreach (var endpoint in client.Endpoints.Cast<ChannelEndpointElement>()) { var contractType = Type.GetType(endpoint.Contract); var serviceType = typeof(WcfService<>).MakeGenericType(contractType); var service = (IWcfService)Activator.CreateInstance(serviceType, endpoint.Name); yield return service; } }