\r\n

51Degrees Device Detection .NET  4.4

Device detection services for 51Degrees Pipeline

FiftyOne.DeviceDetection.Examples.ExampleUtils Class Reference

Static Public Member Functions

static ExampleOptions  ParseOptions (string[] args)
Parse the command line arguments passed to the example to get the common options. More...
static string  FindFile (string filename, DirectoryInfo dir=null)
Uses a background task to search for the specified filename within the working directory. More...
static DataFileInfo  GetDataFileInfo (string dataFile, DeviceDetectionHashEngineBuilder engineBuilder)
Get information about the specified data file More...
static DataFileInfo  GetDataFileInfo (DeviceDetectionHashEngine engine)
Get information about the data file used by the specified engine More...
static void  CheckDataFile (IPipeline pipeline, ILogger logger)
Display information about the data file and log warnings if specific requirements are not met. More...
static void  CheckDataFile (DeviceDetectionHashEngine engine, ILogger logger)
Display information about the data file and log warnings if specific requirements are not met. More...
static void  LogDataFileInfo (DataFileInfo info, ILogger logger)
Display information about the data file and log warnings if specific requirements are not met. More...
static void  LogDataFileStandardWarnings (DataFileInfo info, ILogger logger)
Display information about the data file and log warnings if specific requirements are not met. More...
static bool  IsInvalidKey (string key)
Checks if the supplied 51Degrees resource key / license key is invalid. More...
static void  GetKeyFromEnv (string envVarName, Action< string > setValue)
Checks if an environment variable exists with the key name provided and then runs the action with the value, or an empty string if the key does not exist. More...

Public Attributes

const string  CLOUD_RESOURCE_KEY_ENV_VAR = "SUPER_RESOURCE_KEY"
The default environment variable key used to get the resource key to use when running cloud examples. More...
const string  CLOUD_END_POINT_ENV_VAR = "51D_CLOUD_ENDPOINT"
The default environment variable key used to get the end point URL to use when running cloud examples. More...
const int  DataFileAgeWarning = 30
If data file is older than this number of days then a warning will be displayed. More...

Static Public Attributes

static readonly List< Dictionary< string, object > >  EvidenceValues
This collection contains the various input values that will be passed to the device detection algorithm when running examples More...

Member Function Documentation

◆ CheckDataFile() [1/2]

static void FiftyOne.DeviceDetection.Examples.ExampleUtils.CheckDataFile ( IPipeline   pipeline,
ILogger   logger  
)
static

Display information about the data file and log warnings if specific requirements are not met.

Parameters
pipeline -
logger -

◆ CheckDataFile() [2/2]

static void FiftyOne.DeviceDetection.Examples.ExampleUtils.CheckDataFile ( DeviceDetectionHashEngine   engine,
ILogger   logger  
)
static

Display information about the data file and log warnings if specific requirements are not met.

Parameters
engine -
logger -

◆ FindFile()

static string FiftyOne.DeviceDetection.Examples.ExampleUtils.FindFile ( string   filename,
DirectoryInfo   dir = null  
)
static

Uses a background task to search for the specified filename within the working directory.

If the file cannot be found, the algorithm will move to the parent directory and repeat the process. This continues until the file is found or a timeout is triggered.

Parameters
filename -
dir - The directory to start looking from. If not provided the current directory is used.
Returns

◆ GetDataFileInfo() [1/2]

static DataFileInfo FiftyOne.DeviceDetection.Examples.ExampleUtils.GetDataFileInfo ( string   dataFile,
DeviceDetectionHashEngineBuilder   engineBuilder  
)
static

Get information about the specified data file

Parameters
dataFile -
engineBuilder -

◆ GetDataFileInfo() [2/2]

static DataFileInfo FiftyOne.DeviceDetection.Examples.ExampleUtils.GetDataFileInfo ( DeviceDetectionHashEngine   engine )
static

Get information about the data file used by the specified engine

Parameters
engine -

◆ GetKeyFromEnv()

static void FiftyOne.DeviceDetection.Examples.ExampleUtils.GetKeyFromEnv ( string   envVarName,
Action< string >   setValue  
)
static

Checks if an environment variable exists with the key name provided and then runs the action with the value, or an empty string if the key does not exist.

Parameters
envVarName -
setValue -

◆ IsInvalidKey()

static bool FiftyOne.DeviceDetection.Examples.ExampleUtils.IsInvalidKey ( string   key )
static

Checks if the supplied 51Degrees resource key / license key is invalid.

Note that this cannot determine if the key is definitely valid, just whether it is definitely invalid.

Parameters
key - The key to check.
Returns

◆ LogDataFileInfo()

static void FiftyOne.DeviceDetection.Examples.ExampleUtils.LogDataFileInfo ( DataFileInfo   info,
ILogger   logger  
)
static

Display information about the data file and log warnings if specific requirements are not met.

Parameters
engine -
logger -

◆ LogDataFileStandardWarnings()

static void FiftyOne.DeviceDetection.Examples.ExampleUtils.LogDataFileStandardWarnings ( DataFileInfo   info,
ILogger   logger  
)
static

Display information about the data file and log warnings if specific requirements are not met.

Parameters
engine -
logger -

◆ ParseOptions()

static ExampleOptions FiftyOne.DeviceDetection.Examples.ExampleUtils.ParseOptions ( string []   args )
static

Parse the command line arguments passed to the example to get the common options.

Parameters
args - Command line options.
Returns
Parsed options, or null if help output is requested.
Exceptions
ArgumentException - If an invalid argument is passed.

Member Data Documentation

◆ CLOUD_END_POINT_ENV_VAR

const string FiftyOne.DeviceDetection.Examples.ExampleUtils.CLOUD_END_POINT_ENV_VAR = "51D_CLOUD_ENDPOINT"

The default environment variable key used to get the end point URL to use when running cloud examples.

Can be used to override the appsettings.json configuration for testing custom end points.

◆ CLOUD_RESOURCE_KEY_ENV_VAR

const string FiftyOne.DeviceDetection.Examples.ExampleUtils.CLOUD_RESOURCE_KEY_ENV_VAR = "SUPER_RESOURCE_KEY"

The default environment variable key used to get the resource key to use when running cloud examples.

◆ DataFileAgeWarning

const int FiftyOne.DeviceDetection.Examples.ExampleUtils.DataFileAgeWarning = 30

If data file is older than this number of days then a warning will be displayed.

◆ EvidenceValues

readonly List<Dictionary<string, object> > FiftyOne.DeviceDetection.Examples.ExampleUtils.EvidenceValues
static

This collection contains the various input values that will be passed to the device detection algorithm when running examples