示例#1
0
 static DeviceScreen ToDeviceInfo(DeviceJson json)
 {
     return(new DeviceScreen(
                json.Name,
                new Size <Pixels>(json.Width, json.Height),
                json.PixelsPerPoint,
                json.PhysicalPixelsPerInch,
                json.PhysicalPixelsPerPixel,
                json.DefaultOrientation.ToUpper() == "LANDSCAPE"
                                 ? DeviceOrientation.Landscape
                                 : DeviceOrientation.Portrait,
                json.IsDefault));
 }
示例#2
0
 /// <exception cref="MalformedDeviceInfo"></exception>
 public static ImmutableList <DeviceScreen> LoadDevicesFrom(Stream stream)
 {
     try
     {
         return(DeviceJson
                .LoadFrom(stream)
                .Select(ToDeviceInfo)
                .ToImmutableList());
     }
     catch (Exception e)
     {
         throw new MalformedDeviceInfo(e);
     }
 }