public static void Main()
Console.WriteLine(DeviceDetectors.ParseUserAgent("Mozilla/5.0 (iPad; CPU OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/343.0.695551749 Mobile/15E148 Safari/604.1").DeviceType);
Console.WriteLine(DeviceDetectors.ParseUserAgent("Mozilla/5.0 (iPad; CPU OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/343.0.695551749 Mobile/15E148 Safari/604.1").IsTablet);
public enum UserDeviceEnum
public bool IsBot { set; get; }
public bool IsMobile { set; get; }
public bool IsTablet { set; get; }
public bool IsDesktop { set; get; }
public virtual UserDeviceEnum DeviceType => IsBot? UserDeviceEnum.Bot :
IsDesktop ? UserDeviceEnum.Desktop: IsTablet ?UserDeviceEnum.Tablet : IsMobile? UserDeviceEnum.Mobile : UserDeviceEnum.Other;
public static class DeviceDetectors
private static readonly DeviceDetector DeviceDetector = new();
public static UserDevice ParseUserAgent(string userAgent)
DeviceDetector.SetUserAgent(userAgent);
if (DeviceDetector.IsParsed())
IsBot = DeviceDetector.IsBot(),
IsMobile = DeviceDetector.IsMobile(),
IsDesktop = DeviceDetector.IsDesktop(),
IsTablet = DeviceDetector.IsTablet()