ua_parser C# Library
======================
This is the CSharp implementation of [ua-parser](https://github.com/tobie/ua-parser). You can find the latest binaries on NuGet [here](https://www.nuget.org/packages/UAParser/).
[![Build status](https://ci.appveyor.com/api/projects/status/ery4ydoxwtokgjkm?svg=true)](https://ci.appveyor.com/project/enemaerke/uap-csharp)
The implementation uses the shared regex patterns and overrides from regexes.yaml (found in [uap-core](https://github.com/ua-parser/uap-core)). The assembly embeds the latest regex patterns (enabled through a git submodule) which are loaded into the default parser. You can create a parser with more updated regex patterns by using the static methods on `Parser` to pass in specific patterns in yaml format.
Build and Run Tests:
------
Make sure you pull down the submodules that includes the yaml files (otherwise you won't be able to compile):
git submodule update --init --recursive
You can then build and run the tests by invoking the `build.bat` script
.\build.bat
Update the embedded regexes
------
To pull the latest regexes into the project:
cd uap-core
git pull origin master
Usage:
--------
```csharp
using UAParser;
...
string uaString = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3";
// get a parser with the embedded regex patterns
var uaParser = Parser.GetDefault();
// get a parser using externally supplied yaml definitions
// var uaParser = Parser.FromYaml(yamlString);
ClientInfo c = uaParser.Parse(uaString);
Console.WriteLine(c.UA.Family); // => "Mobile Safari"
Console.WriteLine(c.UA.Major); // => "5"
Console.WriteLine(c.UA.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"
```
Authors:
-------
* Søren Enemærke [@sorenenemaerke](https://twitter.com/sorenenemaerke) / [github](https://github.com/enemaerke)
* Atif Aziz [@raboof](https://twitter.com/raboof) / [github](https://github.com/atifaziz)
C# implementation of ua-parser.zip
需积分: 5 131 浏览量
2024-01-05
14:28:18
上传
评论
收藏 1.09MB ZIP 举报
Lei宝啊
- 粉丝: 2080
- 资源: 1330
最新资源
- matlab画图教程.docx
- 基于MNIST数据集卷积神经网络实现手写数字识别(GUI).zip
- 一个MATLAB仿真设计的例子,演示如何对一个模拟信号进行傅里叶变换:
- 10-Hadoop(HA)V4.0.docx
- 基于MNIST数据集卷积神经网络实现手写数字识别(GUI)源码+文档说明
- 自定义函数在后缀表达式中的应用与实现
- 使用python爬取天气信息(包括历史天气数据)_python爬取天气数据-CSDN博客.html
- 毕设项目:高校学生宿舍管理系统的设计与实现(ASP.NET+源代码+论文)
- Navicat入门教程.docx
- os.path.join(root, 'test-average-edge-map'
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈