System.Net.CredentialHostKey.Match C# (CSharp) Method

Match() private method

private Match ( string host, int port, string authenticationType ) : bool
host string
port int
authenticationType string
return bool
        internal bool Match(string host, int port, string authenticationType) {
            if (host==null || authenticationType==null) {
                return false;
            }
            //
            // If the protocols dont match this credential
            // is not applicable for the given Uri
            //
            if (string.Compare(authenticationType, AuthenticationType, StringComparison.OrdinalIgnoreCase) != 0) {
                return false;
            }
            if (string.Compare(Host, host, StringComparison.OrdinalIgnoreCase ) != 0) {
                return false;
            }
            if (port != Port) {
                return false;
            }

            GlobalLog.Print("CredentialKey::Match(" + Host.ToString() + ":" + Port.ToString() +" & " + host.ToString() + ":" + port.ToString() + ")");
            return true;
        }

Usage Example

Beispiel #1
0
        public NetworkCredential GetCredential(string host, int port, string authenticationType)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (authenticationType == null)
            {
                throw new ArgumentNullException("authenticationType");
            }
            if (host.Length == 0)
            {
                throw new ArgumentException(SR.GetString("net_emptystringcall", new object[] { "host" }));
            }
            if (port < 0)
            {
                throw new ArgumentOutOfRangeException("port");
            }
            NetworkCredential     credential = null;
            IDictionaryEnumerator enumerator = this.cacheForHosts.GetEnumerator();

            while (enumerator.MoveNext())
            {
                CredentialHostKey key = (CredentialHostKey)enumerator.Key;
                if (key.Match(host, port, authenticationType))
                {
                    credential = (NetworkCredential)enumerator.Value;
                }
            }
            return(credential);
        }
All Usage Examples Of System.Net.CredentialHostKey::Match