BF2Statistics.HostsFile.Get C# (CSharp) Method

Get() public method

Returns the IP address for the provided domain name
public Get ( string Domain ) : IPAddress
Domain string The domain name
return System.Net.IPAddress
        public IPAddress Get(string Domain)
        {
            return Entries[Domain];
        }

Usage Example

        /// <summary>
        /// Queries the DNS Cache for the Gamespy hosts, and verifies that the
        /// IP addresses in the DNS Cache match that of the desired redirect IP
        /// </summary>
        public static bool VerifyDNSCache(IProgress <DnsCacheResult> Progress = null)
        {
            // Nothing to do here if redirects are disabled
            if (!RedirectsEnabled)
            {
                return(false);
            }

            // Grab our saved hosts file IP addresses
            if (RedirectMethod != RedirectMode.DnsServer)
            {
                // Grab hosts file base
                HostsFile hFile = (RedirectMethod == RedirectMode.HostsFile)
                    ? HostsFileSys as HostsFile
                    : HostsFileIcs as HostsFile;

                // Fetch our saved IPAddresses
                GamespyServerAddress = (hFile.HasEntry("master.gamespy.com")) ? hFile.Get("master.gamespy.com") : null;
                StatsServerAddress   = (hFile.HasEntry(Bf2StatsHost)) ? hFile.Get(Bf2StatsHost) : null;
            }

            // Flush our cache report
            DnsCacheReport.Entries.Clear();

            // Verify Gamespy Server IP addresses
            if (GamespyServerAddress != null)
            {
                foreach (string address in GamespyHosts)
                {
                    // Create new report
                    DnsCacheResult Result = new DnsCacheResult(address, GamespyServerAddress);

                    // Add the result to the report
                    DnsCacheReport.AddOrUpdate(Result);

                    // Report progress if we have a progress object
                    if (Progress != null)
                    {
                        Progress.Report(Result);
                    }
                }
            }

            // Verify Stats Server address
            if (StatsServerAddress != null)
            {
                // Create new report
                DnsCacheResult Result = new DnsCacheResult(Bf2StatsHost, StatsServerAddress);

                // Add the result to the report
                DnsCacheReport.AddOrUpdate(Result);

                // Report progress if we have a progress object
                if (Progress != null)
                {
                    Progress.Report(Result);
                }
            }

            // Set internal
            DnsCacheReport.LastRefresh = DateTime.Now;
            return(DnsCacheReport.ErrorFree);
        }
All Usage Examples Of BF2Statistics.HostsFile::Get