Exemplo n.º 1
0
 public bool EndQuery(IAsyncResult ar, out IPAddress[] providerResult)
 {
     Provider.QueryAsyncResult queryAsyncResult = ar as Provider.QueryAsyncResult;
     if (queryAsyncResult != null && queryAsyncResult.IsCompleted)
     {
         providerResult = queryAsyncResult.ProviderResult;
         return(queryAsyncResult.IsMatch);
     }
     throw new InvalidOperationException();
 }
Exemplo n.º 2
0
        private void DnsQueryCallback(IAsyncResult ar)
        {
            IPAddress[] array;
            DnsStatus   dnsStatus = Dns.EndResolveToAddresses(ar, out array);
            bool        isMatch   = false;

            if (dnsStatus == DnsStatus.Success)
            {
                isMatch = this.MatchResult(array);
            }
            Provider.QueryAsyncResult queryAsyncResult = (Provider.QueryAsyncResult)ar.AsyncState;
            queryAsyncResult.QueryCompleted(isMatch, array);
        }
Exemplo n.º 3
0
        public IAsyncResult BeginQuery(IPAddress ipAddress, AsyncCallback asyncCallback, object asyncState)
        {
            Provider.QueryAsyncResult queryAsyncResult = new Provider.QueryAsyncResult(asyncCallback, asyncState);
            queryAsyncResult.SetAsync();
            string       domainName  = string.Format("{0}.{1}", this.ReverseIP(ipAddress), this.provider.LookupDomain);
            IAsyncResult asyncResult = this.dns.BeginResolveToAddresses(domainName, AddressFamily.InterNetwork, new AsyncCallback(this.DnsQueryCallback), queryAsyncResult);

            if (asyncResult.CompletedSynchronously)
            {
                queryAsyncResult.ResetAsync();
            }
            return(queryAsyncResult);
        }