/// <summary> /// returns the ClientEndPoint for a specific contract and a specified name /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> private static ClientEndpoint GetClientEndpoint <T>(string serverAddress, List <IEndpointBehavior> endpointBehaviors) { EndpointAddress baseAddress = new EndpointAddress(serverAddress); var clientEndpoint = new ClientEndpoint(typeof(T), serverAddress); var endpointChannelFactory = new EndpointChannelFactory { EndpointAddress = baseAddress }; endpointChannelFactory.ChannelFactory = new ChannelFactory <T>(ClientServerBindingHelper.GetBinding(false).ApplyClientBasicHttpBinding(), endpointChannelFactory.EndpointAddress); foreach (var endpointBehavior in endpointBehaviors) { endpointChannelFactory.ChannelFactory.Endpoint.Behaviors.Add(endpointBehavior); } endpointChannelFactory.ChannelFactory.Open(); clientEndpoint.Endpoint = endpointChannelFactory; return(clientEndpoint); }
/// <summary> /// returns the ClientEndPoint for a specific contract and a specified name /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> private static DuplexClientEndpoint <T> GetClientEndpoint <T>(string serverAddress, List <IEndpointBehavior> endpointBehaviors, InstanceContext callbackInstance) { EndpointAddress baseAddress = new EndpointAddress(serverAddress); var clientEndpoint = new DuplexClientEndpoint <T>(typeof(T), serverAddress); var endpointChannelFactory = new DuplexEndpointChannelFactory <T> { EndpointAddress = baseAddress }; endpointChannelFactory.ChannelFactory = new DuplexChannelFactory <T>(callbackInstance, ClientServerBindingHelper.GetBinding(true).ApplyClientWsDualHttpBinding(), endpointChannelFactory.EndpointAddress); foreach (var endpointBehavior in endpointBehaviors) { endpointChannelFactory.ChannelFactory.Endpoint.Behaviors.Add(endpointBehavior); } endpointChannelFactory.ChannelFactory.Open(); clientEndpoint.Endpoint = endpointChannelFactory; return(clientEndpoint); }