internal static bool TryCreate(SecurityBindingElement sbe, out BasicHttpRelayMessageSecurity security, out bool isSecureTransportMode)
        {
            BasicHttpMessageCredentialType basicHttpMessageCredentialType;

            Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DebugAssert(null != sbe, string.Empty);
            security = null;
            isSecureTransportMode = false;
            if (!(bool)InvokeHelper.InvokeInstanceGet(sbe.GetType(), sbe, "DoNotEmitTrust"))
            {
                return(false);
            }
            Type type = sbe.GetType();

            object[] objArray = new object[] { false };
            if (!(bool)InvokeHelper.InvokeInstanceMethod(type, sbe, "IsSetKeyDerivation", objArray))
            {
                return(false);
            }
            if (sbe.SecurityHeaderLayout != SecurityHeaderLayout.Lax)
            {
                return(false);
            }
            if (sbe.MessageSecurityVersion != MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10)
            {
                return(false);
            }
            if (SecurityUtil.SecurityBindingElement.IsMutualCertificateBinding(sbe, true))
            {
                basicHttpMessageCredentialType = BasicHttpMessageCredentialType.Certificate;
            }
            else
            {
                isSecureTransportMode = true;
                if (!SecurityUtil.SecurityBindingElement.IsCertificateOverTransportBinding(sbe))
                {
                    if (!SecurityUtil.SecurityBindingElement.IsUserNameOverTransportBinding(sbe))
                    {
                        return(false);
                    }
                    basicHttpMessageCredentialType = BasicHttpMessageCredentialType.UserName;
                }
                else
                {
                    basicHttpMessageCredentialType = BasicHttpMessageCredentialType.Certificate;
                }
            }
            security = new BasicHttpRelayMessageSecurity()
            {
                ClientCredentialType = basicHttpMessageCredentialType,
                AlgorithmSuite       = sbe.DefaultAlgorithmSuite
            };
            return(true);
        }