Exemplo n.º 1
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            object objX = dictionary ["XCoordinate"];
            string sX   = objX.ToString();

            sX = sX.Replace(',', '.');
            double XCoordinate = Double.Parse(sX, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo());

            object objY = dictionary ["YCoordinate"];
            string sY   = objY.ToString();

            sY = sY.Replace(',', '.');
            double YCoordinate = Double.Parse(sY, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo());

            object objZ = dictionary ["ZCoordinate"];
            string sZ   = objZ.ToString();

            sZ = sZ.Replace(',', '.');
            double ZCoordinate = Double.Parse(sZ, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo());

            object objXDop = dictionary ["XDoP"];
            string sXDop   = objXDop.ToString();

            sXDop = sXDop.Replace(',', '.');
            float XDop = Single.Parse(sXDop, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo());

            object objYDop = dictionary ["YDoP"];
            string sYDop   = objYDop.ToString();

            sYDop = sYDop.Replace(',', '.');
            float YDop = Single.Parse(sYDop, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo());

            LocationCoordinate coordinate = new LocationCoordinate();

            coordinate.XCoordinate = XCoordinate;
            coordinate.YCoordinate = YCoordinate;
            coordinate.ZCoordinate = ZCoordinate;
            coordinate.XDoP        = XDop;
            coordinate.YDoP        = YDop;
            return(coordinate);
        }
 public string YDoPString()
 {
     return(YDoP.ToString(FormatUtils.GetNumberFormatInfo()));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the object represented by the
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public override object GetObject(Type type, object json)
        {
            object obj = null;

            if (json != null)
            {
                if (type.FullName == "System.Int32")
                {
                    obj = Int32.Parse(json.ToString());
                    // int
                }
                else if (type.FullName == "System.Int64")
                {
                    obj = Int64.Parse(json.ToString());
                    // long
                }
                else if (type.FullName == "System.Single")
                {
                    obj = Single.Parse(json.ToString(), NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo());
                    // float
                }
                else if (type.FullName == "System.Double")
                {
                    obj = Double.Parse(json.ToString(), NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo());
                    // float
                }
                else if (type.IsEnum)
                {
                    obj = Enum.Parse(type, json.ToString());
                }
                else if (type.FullName == "System.Boolean")
                {
                    obj = Boolean.Parse(json.ToString());
                    // bool
                }
                else if (type.FullName == "System.Byte[]")
                {
                    obj = this.toByteArray((object[])json);
                }
                else if (json is IDictionary)
                {
                    obj = serialiser.ConvertToType(type, ((IDictionary <string, object>)json));
                }
                else if (json is Array)
                {
                    obj = serialiser.ConvertToType(type, json);
                }
                else
                {
                    obj = json;
                }
            }

            return(obj);
        }
 public string YCoordinateString()
 {
     return(YCoordinate.ToString(FormatUtils.GetNumberFormatInfo()));
 }