What's Covered
51Degrees device detector returns all detection results as a string. This tutorial demonstrates how to return results for the IsMobile property value as a boolean.
Code and Explanation
Strongly typed example of using 51Degrees device detection.
The example shows how to:
string fileName = args[0];
DataSet dataSet = StreamFactory.Create(fileName, false);
Provider provider = new Provider(dataSet);
match = provider.Match(userAgent);
if (match["IsMobile"] == "True") return true; else return false;This tutorial assumes you are building this from within the 51Degrees Visual Studio solution. Running the executable produced inside Visual Studio will ensure all the command line arguments are preset correctly. If you are running outside of Visual Studio, make sure to add the path to a 51Degrees data file as an argument.
Summary
In this tutorial you have seen how to use the detector to retrieve the IsMobile property for a pre-defined User-Agent string. It sets a boolean value to true or false from the original string value of "True" or "False", making if statements simpler to test.