51Degrees Device Detection .NET  4.2

Device detection services for 51Degrees Pipeline


This example shows how to use the 51Degrees Cloud service to lookup the details of a device based on a given 'TAC'. More background information on TACs can be found through various online sources such as Wikipedia.

This example is available in full on GitHub.

To run this example, you will need to create a resource key. The resource key is used as shorthand to store the particular set of properties you are interested in as well as any associated license keys that entitle you to increased request limits and/or paid-for properties.

You can create a resource key using the 51Degrees Configurator.

Required NuGet Dependencies:

using FiftyOne.Pipeline.CloudRequestEngine.FlowElements;
using FiftyOne.Pipeline.Core.FlowElements;
using Microsoft.Extensions.Logging;
using System;
using System.Net.Http;
public class Program
public class Example
private static string TAC = "35925406";
private static string TAC2 = "86386802";
public void Run(string resourceKey, string cloudEndPoint = "")
Console.WriteLine("This example shows the details of devices " +
"associated with a given 'Type Allocation Code' or 'TAC'.");
Console.WriteLine("More background information on TACs can be " +
"found through various online sources such as Wikipedia: " +
ILoggerFactory loggerFactory = new LoggerFactory();
HttpClient httpClient = new HttpClient();
// Create a cloud request engine builder
var cloudRequestEngineBuilder = new CloudRequestEngineBuilder(loggerFactory, httpClient)
// If a cloud endpoint has been provided then set the
// cloud pipeline endpoint.
if (string.IsNullOrWhiteSpace(cloudEndPoint) == false)
// Create the cloud request engine
using (var cloudEngine = cloudRequestEngineBuilder.Build())
// Create the property-keyed engine to process the
// response from the request engine.
using (var propertyKeyedEngine = new HardwareProfileCloudEngineBuilder(loggerFactory)
// Create the pipeline using the engines.
using (var pipeline = new PipelineBuilder(loggerFactory)
// Pass a TAC into the pipeline and list the matching devices.
AnalyseTac(TAC, pipeline);
AnalyseTac(TAC2, pipeline);
static void AnalyseTac(string tac, IPipeline pipeline)
// Create the FlowData instance.
using (var data = pipeline.CreateFlowData())
// Add the TAC as evidence.
data.AddEvidence(Constants.EVIDENCE_QUERY_TAC_KEY, tac);
// Process the supplied evidence.
// Get result data from the flow data.
var result = data.Get<MultiDeviceDataCloud>();
Console.WriteLine($"Which devices are associated with the TAC '{tac}'?");
foreach (var device in result.Profiles)
var vendor = device.HardwareVendor;
var name = device.HardwareName;
var model = device.HardwareModel;
// Check that the properties have values.
if (vendor.HasValue &&
model.HasValue &&
Console.WriteLine($"\t{vendor.Value} {string.Join(",", name.Value)} ({model.Value})");
static void Main(string[] args)
// Obtain a resource key for free at https://configure.51degrees.com
// Make sure to include the 'HardwareVendor' and 'HardwareModel'
// properties as they are used by this example.
string resourceKey = "!!YOUR_RESOURCE_KEY!!";
if (resourceKey.StartsWith("!!"))
Console.WriteLine("You need to create a resource key at " +
"https://configure.51degrees.com and paste it into the code, " +
"replacing !!YOUR_RESOURCE_KEY!!.");
Console.WriteLine("Make sure to include the 'HardwareVendor', " +
"'HardwareName' and 'HardwareModel' properties as they " +
"are used by this example.");
new Example().Run(resourceKey);
#if (DEBUG)
Console.WriteLine("Done. Press any key to exit.");