The DeviceAtlas CarrierApi documentation  1.1
 All Classes Namespaces Functions Variables Properties
Public Member Functions | List of all members
Mobi.Mtld.DA.Carrier.CarrierApiWeb Class Reference

More...

Inheritance diagram for Mobi.Mtld.DA.Carrier.CarrierApiWeb:
Mobi.Mtld.DA.Carrier.CarrierApi

Public Member Functions

Properties GetProperties ()
 Get the Carrier properties for the current client. The most suitable client IP is extracted and used to lookup the Carrier properties. More...
 
Properties GetProperties (HttpRequest request)
 Get the Carrier properties for the given HttpWebRequest object. The most suitable client IP is extracted and used to lookup the Carrier properties. More...
 
Property GetProperty (string propertyName)
 
Property GetProperty (HttpRequest request, string propertyName)
 
- Public Member Functions inherited from Mobi.Mtld.DA.Carrier.CarrierApi
 CarrierApi ()
 Construct a Carrier API object More...
 
 CarrierApi (string path)
 Construct a Carrier API object and Load the data file from the provided path. More...
 
void LoadDataFromFile (string path)
 Load the data file from the provided path. The data file is reloaded every time this method is called. More...
 
string GetDataFileCopyright ()
 Returns the data file copyright text. More...
 
string GetDataFileCreationDate ()
 Returns the data file creation date in ISO8601 format. More...
 
string GetDataFileVersion ()
 Returns the version of the data file. More...
 
Properties GetProperties (string ipv4)
 Get the Carrier properties for a given IP address. More...
 
Properties GetProperties (Dictionary< string, string > keyVals)
 
Property GetProperty (string ipv4, string propertyName)
 
Property GetProperty (Dictionary< string, string > keyVals, string propertyName)
 
ReadOnlyCollection< PropertyNameGetPropertyNames ()
 A set of all the possible property names. The Set contains PropertyName objects that each have a string name and an associated data type. More...
 
string GetIp (Dictionary< string, string > keyVals)
 Get the most suitable IP address from the given keyVals set of HTTP headers. This function checks the headers defined in HEADERS_TO_CHECK. More...
 
string ExtractIp (string headerName, string headerValue)
 

Additional Inherited Members

- Static Public Member Functions inherited from Mobi.Mtld.DA.Carrier.CarrierApi
static bool IsPublicIp (string ipStr)
 An IP address is considered public if it is not in any of the following ranges: More...
 
- Static Public Attributes inherited from Mobi.Mtld.DA.Carrier.CarrierApi
static readonly string VERSION = "1.1"
 
static readonly string[] HEADERS_TO_CHECK
 A list of HTTP headers to choose the original client IP address from. In addition to these the RemoteAddr (REMOTE_ADDR) is also used as a final fallback. More...
 
- Protected Member Functions inherited from Mobi.Mtld.DA.Carrier.CarrierApi
void DataLoaded ()
 Check if the given propertyName is not null and exists in the data file More...
 
void PropertyNameExists (string propertyName)
 Throws an exception if the given propertyName is null or not exists in the data file. Calls to this method must be sure that the data object is already loaded. If More...
 

Detailed Description

A small extension to the core CarrierApi to get IP from HttpRequest for current client or permit passing of an HttpRequest object.

The GetProperties() and GetProperty() methods in this class extract the most suitable client IP.

Example usage: <% CarrierApiWeb carrierApi = new CarrierApiWeb(); // loading data can be slow - it is recommended wrap the API in a Singleton. carrierApi.LoadDataFromFile("/path/to/sample.dat");

// get all properties for current client Properties props = carrierApi.GetProperties(request);

// .... use the properties .... if (props.ContainsKey("networkOperator") { string operatorName = props.Get("networkOperator").AsString(); }

// get a single property Property countryProp = carrierApi.GetProperty("countryCode"); if (countryProp != null) { string countryCode = countryProp.AsString(); }

Author
DeviceAtlas Limited

Member Function Documentation

Properties Mobi.Mtld.DA.Carrier.CarrierApiWeb.GetProperties ( )
inline

Get the Carrier properties for the current client. The most suitable client IP is extracted and used to lookup the Carrier properties.

Returns
The found properties or null of no properties found.
Properties Mobi.Mtld.DA.Carrier.CarrierApiWeb.GetProperties ( HttpRequest  request)
inline

Get the Carrier properties for the given HttpWebRequest object. The most suitable client IP is extracted and used to lookup the Carrier properties.

Parameters
requestThe request object to find the most suitable IP from.
Returns
The found properties or null of no properties found.
Property Mobi.Mtld.DA.Carrier.CarrierApiWeb.GetProperty ( string  propertyName)
inline

Get a specific Property from the current client IP found. The most suitable client IP is extracted from the HttpWebRequest object.

Note: if multiple properties are needed for the same IP it is more efficient to call GetProperties() once than repeated calls to GetProperty().

Parameters
propertyName The name of the property to return
Returns
The found property or null of no property found.
Exceptions
InvalidPropertyNameExceptionThrown if the property name does not exist.
Property Mobi.Mtld.DA.Carrier.CarrierApiWeb.GetProperty ( HttpRequest  request,
string  propertyName 
)
inline

Get a specific Property from the IP found in the HttpWebRequest object. The most suitable client IP is extracted from the HttpWebRequest object.

Note: if multiple properties are needed for the same IP it is more efficient to call GetProperties() once than repeated calls to GetProperty().

Parameters
requestThe request object to find the most suitable IP from.
propertyName The name of the property to return
Returns
The found property or null of no property found.
Exceptions
InvalidPropertyNameExceptionThrown if the property name does not exist.

The documentation for this class was generated from the following file: