Ejemplo n.º 1
0
 private bool IsBindingElementsMatch(HttpRelayTransportBindingElement transport, MessageEncodingBindingElement encoding, System.ServiceModel.Channels.ReliableSessionBindingElement session)
 {
     if (!WSHttpRelayBindingBase.IsBindingElementMatch(this.GetTransport(), transport))
     {
         return(false);
     }
     if (this.MessageEncoding == WSMessageEncoding.Text)
     {
         if (!WSHttpRelayBindingBase.IsBindingElementMatch(this.textEncoding, encoding))
         {
             return(false);
         }
     }
     else if (this.MessageEncoding == WSMessageEncoding.Mtom && !WSHttpRelayBindingBase.IsBindingElementMatch(this.mtomEncoding, encoding))
     {
         return(false);
     }
     if (this.reliableSession.Enabled)
     {
         if (!WSHttpRelayBindingBase.IsBindingElementMatch(this.session, session))
         {
             return(false);
         }
     }
     else if (session != null)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 2
0
        internal static bool TryCreate(BindingElementCollection elements, out Binding binding)
        {
            bool flag;

            binding = null;
            if (elements.Count > 5)
            {
                return(false);
            }
            PrivacyNoticeBindingElement privacyNoticeBindingElement = null;

            System.ServiceModel.Channels.ReliableSessionBindingElement reliableSessionBindingElement = null;
            SecurityBindingElement           securityBindingElement           = null;
            MessageEncodingBindingElement    messageEncodingBindingElement    = null;
            HttpRelayTransportBindingElement httpRelayTransportBindingElement = null;

            using (IEnumerator <BindingElement> enumerator = elements.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BindingElement current = enumerator.Current;
                    if (current is SecurityBindingElement)
                    {
                        securityBindingElement = current as SecurityBindingElement;
                    }
                    else if (current is HttpsRelayTransportBindingElement)
                    {
                        httpRelayTransportBindingElement = current as HttpsRelayTransportBindingElement;
                    }
                    else if (current is HttpRelayTransportBindingElement)
                    {
                        httpRelayTransportBindingElement = current as HttpRelayTransportBindingElement;
                    }
                    else if (current is MessageEncodingBindingElement)
                    {
                        messageEncodingBindingElement = current as MessageEncodingBindingElement;
                    }
                    else if (current is System.ServiceModel.Channels.ReliableSessionBindingElement)
                    {
                        reliableSessionBindingElement = current as System.ServiceModel.Channels.ReliableSessionBindingElement;
                    }
                    else if (!(current is PrivacyNoticeBindingElement))
                    {
                        flag = false;
                        return(flag);
                    }
                    else
                    {
                        privacyNoticeBindingElement = current as PrivacyNoticeBindingElement;
                    }
                }
                if (httpRelayTransportBindingElement == null)
                {
                    return(false);
                }
                if (messageEncodingBindingElement == null)
                {
                    return(false);
                }
                if (privacyNoticeBindingElement != null || !WS2007HttpRelayBinding.TryCreate(securityBindingElement, httpRelayTransportBindingElement.RelayClientAuthenticationType, httpRelayTransportBindingElement, reliableSessionBindingElement, out binding))
                {
                    return(false);
                }
                WSHttpRelayBindingBase wSHttpRelayBindingBase = binding as WSHttpRelayBindingBase;
                wSHttpRelayBindingBase.InitializeFrom(httpRelayTransportBindingElement, messageEncodingBindingElement, reliableSessionBindingElement);
                if (!wSHttpRelayBindingBase.IsBindingElementsMatch(httpRelayTransportBindingElement, messageEncodingBindingElement, reliableSessionBindingElement))
                {
                    return(false);
                }
                return(true);
            }
            return(flag);
        }