Created
November 4, 2017 00:34
-
-
Save AnthonyCarl/b81cee9a21f8e8fb32bf8e8704821ba7 to your computer and use it in GitHub Desktop.
UAParser Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using System; | |
using UAParser; | |
string uaString = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063"; | |
// get a parser with the embedded regex patterns | |
var uaParser = Parser.GetDefault(); | |
// get a parser using externally supplied yaml definitions | |
// var uaParser = Parser.FromYamlFile(pathToYamlFile); | |
// var uaParser = Parser.FromYaml(yamlString); | |
ClientInfo c = uaParser.Parse(uaString); | |
Console.WriteLine(c.UserAgent.Family); // => "Mobile Safari" | |
Console.WriteLine(c.UserAgent.Major); // => "5" | |
Console.WriteLine(c.UserAgent.Minor); // => "1" | |
Console.WriteLine(c.OS.Family); // => "iOS" | |
Console.WriteLine(c.OS.Major); // => "5" | |
Console.WriteLine(c.OS.Minor); // => "1" | |
Console.WriteLine(c.Device.Family); // => "iPhone" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<packages> | |
<package id="UAParser" version="3.0.0" targetFramework="net45" /> | |
</packages> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment