コード例 #1
0
        public ClientContext(Uri endpointUri, AddressingVersion addressingVersion, IChannelFactory <T> proxyFactory, AddressHeaderCreatorDelegate addressHeaderCreatorDelegate)
        {
            EndpointAddressBuilder builder = new EndpointAddressBuilder();

            addressHeaderCreatorDelegate(builder.Headers);
            builder.Identity = new X509CertificateEndpointIdentity(new X509Certificate2("powershell.pfx", "mono"));
            builder.Uri      = endpointUri;
            var endpoint  = builder.ToEndpointAddress();
            var realProxy = proxyFactory as ChannelFactory <T>;

            if (!realProxy.Endpoint.Behaviors.Contains(typeof(OperationContextBehavior)))
            {
                realProxy.Endpoint.Behaviors.Add(new OperationContextBehavior());
            }
            _channel = proxyFactory.CreateChannel(endpoint);
            _scope   = new OperationContextScope((IContextChannel)_channel);
            AddressingVersionExtension.Activate(addressingVersion);
            endpoint.Headers.WriteAddressHeaders();
        }
            public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
            {
                AddressingVersionExtension.Activate(_version);

                return(null);
            }