C# Class MaxMind.GeoIPCountry

Inheritance: IDisposable
Datei anzeigen Open project: NyxStudios/TShock Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void
GeoIPCountry ( Stream datafile ) : System

Initialises a new instance of this class.

The stream is not closed when this class is disposed. Be sure to clean up afterwards!

GeoIPCountry ( string filename ) : System

Initialises a new instance of this class, using an on-disk database.

The file will be closed when this class is disposed.

GetCountryCode ( IPAddress ip ) : string

Retrieves a two-letter code, defined by MaxMind, which details the country the specified IP address is located.

The IP address must be IPv4.

GetCountryNameByCode ( string countrycode ) : string

Gets the English name of a country, by a country code.

TryGetCountryCode ( IPAddress ip ) : string

Retrieves a two-letter code, defined by MaxMind, which details the country the specified IP address is located. Does not throw exceptions on failure.

Private Methods

Method Description
AddressToLong ( IPAddress ip ) : long
FindCountryCode ( long offset, long ipnum, int depth ) : long
FindIndex ( IPAddress ip ) : int

Method Details

Dispose() public method

public Dispose ( ) : void
return void

GeoIPCountry() public method

Initialises a new instance of this class.
The stream is not closed when this class is disposed. Be sure to clean up afterwards!
public GeoIPCountry ( Stream datafile ) : System
datafile Stream An already open stream pointing to the contents of a GeoIP.dat file.
return System

GeoIPCountry() public method

Initialises a new instance of this class, using an on-disk database.
The file will be closed when this class is disposed.
public GeoIPCountry ( string filename ) : System
filename string Path to database file.
return System

GetCountryCode() public method

Retrieves a two-letter code, defined by MaxMind, which details the country the specified IP address is located.
The IP address must be IPv4.
public GetCountryCode ( IPAddress ip ) : string
ip System.Net.IPAddress IP address to query.
return string

GetCountryNameByCode() public static method

Gets the English name of a country, by a country code.
public static GetCountryNameByCode ( string countrycode ) : string
countrycode string Country code to look up, returned by GetCountryCode or TryGetCountryCode.
return string

TryGetCountryCode() public method

Retrieves a two-letter code, defined by MaxMind, which details the country the specified IP address is located. Does not throw exceptions on failure.
public TryGetCountryCode ( IPAddress ip ) : string
ip System.Net.IPAddress IP address to query.
return string