示例#1
0
        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));
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
 protected virtual ICommunicationObject CreateChannel <TChannel>(ChannelFactory <TChannel> factory, SoapChannelCreationContext context)
 => factory.CreateChannel() as ICommunicationObject;
示例#5
0
 protected virtual ChannelFactory <TChannel> CreateChannelFactory <TChannel>(Binding binding, EndpointAddress endpointAddress, SoapChannelCreationContext context)
 => new ChannelFactory <TChannel>(binding, endpointAddress);
示例#6
0
 protected virtual EndpointAddress CreateEndpointAddress <TChannel>(Uri url, SoapChannelCreationContext context)
 => new EndpointAddress(url);