Exemplo n.º 1
0
        public static Size GetSize(this JsonObject data)
        {
            if (data == null)
            {
                return(default(Size));
            }
            double width  = 0;
            double height = 0;

            IJsonValue widthNode = null;

            if (data.ContainsKey("Width"))
            {
                widthNode = data["Width"];
            }
            else if (data.ContainsKey("width"))
            {
                widthNode = data["width"];
            }
            if (widthNode != null)
            {
                if (!widthNode.TryGetDouble(out width))
                {
                    width = 0;
                }
            }
            IJsonValue heightNode = null;

            if (data.ContainsKey("Height"))
            {
                heightNode = data["Height"];
            }
            else if (data.ContainsKey("height"))
            {
                heightNode = data["height"];
            }
            if (heightNode != null)
            {
                if (!heightNode.TryGetDouble(out height))
                {
                    width = 0;
                }
            }

            return(new Size(width, height));
        }