public virtual TChannel CreateChannel <TChannel>(MessageVersion version = null, string path = null, bool reusable = true) where TChannel : class { var context = SoapChannelCreationContext.Create <TChannel>(path, version, reusable); return(CreateChannel <TChannel>(context)); }
protected virtual Binding CreateBinding <TContract>(SoapChannelCreationContext context) { var binding = new CustomBinding(new BasicHttpBinding()) { }; var encoding = binding.Elements.Find <TextMessageEncodingBindingElement>(); encoding.MessageVersion = context.MessageVersion; return(binding); }
protected virtual TChannel CreateChannel <TChannel>(SoapChannelCreationContext context) where TChannel : class { return(_channels.GetOrAdd(context.Id, k => { var url = TestingServer.BaseAddress; if (context.Path != null) { url = new Uri(url, context.Path); } var binding = CreateBinding <TChannel>(context).WithSolidHttpTransport(TestingServer); var endpointAddress = CreateEndpointAddress <TChannel>(url, context); var factory = CreateChannelFactory <TChannel>(binding, endpointAddress, context); var channel = CreateChannel(factory, context); channel.Faulted += (sender, args) => _channels.TryRemove(k, out _); channel.Closing += (sender, args) => _channels.TryRemove(k, out _); return channel; }) as TChannel); }
protected virtual ICommunicationObject CreateChannel <TChannel>(ChannelFactory <TChannel> factory, SoapChannelCreationContext context) => factory.CreateChannel() as ICommunicationObject;
protected virtual ChannelFactory <TChannel> CreateChannelFactory <TChannel>(Binding binding, EndpointAddress endpointAddress, SoapChannelCreationContext context) => new ChannelFactory <TChannel>(binding, endpointAddress);
protected virtual EndpointAddress CreateEndpointAddress <TChannel>(Uri url, SoapChannelCreationContext context) => new EndpointAddress(url);