コード例 #1
0
        protected override void InitializeFrom(BindingElement bindingElement)
        {
            base.InitializeFrom(bindingElement);
            HttpRelayTransportBindingElement httpRelayTransportBindingElement = (HttpRelayTransportBindingElement)bindingElement;

            this.AllowCookies = httpRelayTransportBindingElement.AllowCookies;
            this.RelayClientAuthenticationType = httpRelayTransportBindingElement.RelayClientAuthenticationType;
            this.KeepAliveEnabled              = httpRelayTransportBindingElement.KeepAliveEnabled;
            this.MaxBufferSize                 = httpRelayTransportBindingElement.MaxBufferSize;
            this.ProxyAddress                  = httpRelayTransportBindingElement.ProxyAddress;
            this.ProxyAuthenticationScheme     = httpRelayTransportBindingElement.ProxyAuthenticationScheme;
            this.RelayClientAuthenticationType = httpRelayTransportBindingElement.RelayClientAuthenticationType;
            this.TransferMode                  = httpRelayTransportBindingElement.TransferMode;
            this.UseDefaultWebProxy            = httpRelayTransportBindingElement.UseDefaultWebProxy;
            this.IsDynamic = httpRelayTransportBindingElement.IsDynamic;
        }
        void System.ServiceModel.Description.IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context)
        {
            if (importer == null)
            {
                throw new ArgumentNullException("importer");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            ICollection <XmlElement>         bindingAssertions = context.GetBindingAssertions();
            List <XmlElement>                xmlElements       = new List <XmlElement>();
            HttpRelayTransportBindingElement httpsRelayTransportBindingElement = null;

            foreach (XmlElement bindingAssertion in bindingAssertions)
            {
                if (!(bindingAssertion.NamespaceURI == "http://schemas.microsoft.com/netservices/2009/05/servicebus/connect") || !(bindingAssertion.LocalName == "SenderRelayCredential"))
                {
                    if (bindingAssertion.NamespaceURI != "http://schemas.microsoft.com/netservices/2009/05/servicebus/connect")
                    {
                        continue;
                    }
                    return;
                }
                else
                {
                    httpsRelayTransportBindingElement = new HttpsRelayTransportBindingElement()
                    {
                        RelayClientAuthenticationType = RelayClientAuthenticationType.RelayAccessToken
                    };
                    xmlElements.Add(bindingAssertion);
                }
            }
            if (httpsRelayTransportBindingElement != null)
            {
                context.BindingElements.Remove <TransportBindingElement>();
                context.BindingElements.Add(httpsRelayTransportBindingElement);
            }
            for (int i = 0; i < xmlElements.Count; i++)
            {
                bindingAssertions.Remove(xmlElements[i]);
            }
        }
コード例 #3
0
        public override void ApplyConfiguration(BindingElement bindingElement)
        {
            base.ApplyConfiguration(bindingElement);
            HttpRelayTransportBindingElement allowCookies = (HttpRelayTransportBindingElement)bindingElement;

            allowCookies.AllowCookies = this.AllowCookies;
            allowCookies.RelayClientAuthenticationType = this.RelayClientAuthenticationType;
            allowCookies.KeepAliveEnabled = this.KeepAliveEnabled;
            if (base.ElementInformation.Properties["maxBufferSize"].ValueOrigin != PropertyValueOrigin.Default)
            {
                allowCookies.MaxBufferSize = this.MaxBufferSize;
            }
            allowCookies.ProxyAddress = this.ProxyAddress;
            allowCookies.ProxyAuthenticationScheme     = this.ProxyAuthenticationScheme;
            allowCookies.RelayClientAuthenticationType = this.RelayClientAuthenticationType;
            allowCookies.TransferMode       = this.TransferMode;
            allowCookies.UseDefaultWebProxy = this.UseDefaultWebProxy;
            allowCookies.IsDynamic          = this.IsDynamic;
        }