Opc.Ua.ServerTest.ServerTestClient.IsEndpointSelected C# (CSharp) Method

IsEndpointSelected() private method

Determines whether the endpoint is selected.
private IsEndpointSelected ( ConfiguredEndpoint endpoint, EndpointSelection selection, bool useXml ) : bool
endpoint ConfiguredEndpoint The endpoint.
selection EndpointSelection The selection.
useXml bool if set to true then the XML encoding is used..
return bool
        private bool IsEndpointSelected(ConfiguredEndpoint endpoint, EndpointSelection selection, bool useXml)
        {
            if (selection == EndpointSelection.Single)
            {
                return true;
            }

            // don't allow pipes when testing across a network.
            if (endpoint.EndpointUrl.Scheme == Utils.UriSchemeNetPipe)
            {
                if (!String.Equals(endpoint.EndpointUrl.DnsSafeHost, System.Net.Dns.GetHostName(), StringComparison.OrdinalIgnoreCase))
                {
                    if (!String.Equals(endpoint.EndpointUrl.DnsSafeHost, "localhost", StringComparison.OrdinalIgnoreCase))
                    {
                        return false;
                    }
                }
            }

            if (selection == EndpointSelection.All)
            {
                return true;
            }

            switch (selection)
            {
                case EndpointSelection.AllEncryptAndSign:
                {
                    if (endpoint.Description.SecurityMode == MessageSecurityMode.SignAndEncrypt)
                    {
                        return true;
                    }

                    return false;
                }

                case EndpointSelection.AllSign:
                {
                    if (endpoint.Description.SecurityMode == MessageSecurityMode.Sign)
                    {
                        return true;
                    }

                    return false;
                }

                case EndpointSelection.AllNoSecurity:
                {
                    if (endpoint.Description.SecurityMode == MessageSecurityMode.None)
                    {
                        return true;
                    }

                    return false;
                }

                case EndpointSelection.AllHttpBinary:
                {
                    if (!useXml && endpoint.EndpointUrl.Scheme != Utils.UriSchemeOpcTcp)
                    {
                        return true;
                    }

                    return false;
                }

                case EndpointSelection.AllHttpXml:
                {
                    if (useXml && endpoint.EndpointUrl.Scheme != Utils.UriSchemeOpcTcp)
                    {
                        return true;
                    }

                    return false;
                }

                case EndpointSelection.AllUaTcp:
                {
                    if (endpoint.EndpointUrl.Scheme == Utils.UriSchemeOpcTcp)
                    {
                        return true;
                    }

                    return false;
                }
            }

            return true;
        }