Esempio n. 1
0
 static DevicePayload LoadFromJSONV1(RootObject.Device json) => new DevicePayload
 {
     Type              = json.Type,
     UserAgent         = json.UserAgent,
     Capabilities      = json.Capabilities.ToHashSet(),
     DeviceScaleFactor = json.Screen.DevicePixelRatio,
     Horizontal        = new ViewportPayload
     {
         Height = json.Screen.Horizontal.Height,
         Width  = json.Screen.Horizontal.Width
     },
     Vertical = new ViewportPayload
     {
         Height = json.Screen.Vertical.Height,
         Width  = json.Screen.Vertical.Width
     }
 };
Esempio n. 2
0
        static OutputDevice CreateDevice(string chromeVersion, string deviceName, RootObject.Device descriptor, bool landscape)
        {
            var devicePayload   = LoadFromJSONV1(descriptor);
            var viewportPayload = landscape ? devicePayload.Horizontal : devicePayload.Vertical;

            return(new OutputDevice
            {
                Name = deviceName + (landscape ? " landscape" : string.Empty),
                UserAgent = devicePayload.UserAgent.Replace("%s", chromeVersion),
                Viewport = new OutputDevice.OutputDeviceViewport
                {
                    Width = viewportPayload.Width,
                    Height = viewportPayload.Height,
                    DeviceScaleFactor = devicePayload.DeviceScaleFactor,
                    IsMobile = devicePayload.Capabilities.Contains("mobile"),
                    HasTouch = devicePayload.Capabilities.Contains("touch"),
                    IsLandscape = landscape
                }
            });
        }