public ClientDevice Detect(WebPageContext context)
        {
            ClientDevice mobile  = new ClientDevice();
            var          request = context.Request;

            if (request.Browser.IsMobileDevice)
            {
                mobile.IsMobile = true;
            }
            else
            {
                var userAgent = request.UserAgent;
                if (!string.IsNullOrEmpty(userAgent))
                {
                    using (var item = _regexPool.Borrow())
                    {
                        Regex reg = item.Item;
                        if (reg.IsMatch(userAgent))
                        {
                            mobile.IsMobile = true;
                        }
                    }
                }
            }
            return(mobile);
        }
Exemple #2
0
 private string GetDeviceType(ClientDevice device)
 {
     return(device.IsMobile ? "mobile" : "pc");
 }
Exemple #3
0
 public CacheVariable(string url, HttpCompressionType compressionType, ClientDevice device)
 {
     this.Url             = url;
     this.CompressionType = compressionType;
     this.Device          = device;
 }