Exemple #1
0
        public static GeographyStatistics FromXml(string xml)
        {
            GeographyStatisticsSerializable serializable = GeographyStatisticsSerializable.FromXml(xml);

            var result = new GeographyStatistics();

            foreach (GeographyDataPoint dataPoint in serializable)
            {
                result[dataPoint.GeographyId] = dataPoint;
                result[dataPoint.GeographyId].GeographyName = HttpUtility.HtmlDecode(dataPoint.GeographyName);
            }

            return(result);
        }
Exemple #2
0
        public string ToXml()
        {
            // Serialize through a GeographyStatisticsSerializable.

            var serializable = new GeographyStatisticsSerializable();

            foreach (GeographyDataPoint dataPoint in Values)
            {
                dataPoint.GeographyName = HttpUtility.HtmlEncode(dataPoint.GeographyName);
                serializable.Add(dataPoint);
            }

            return(serializable.ToXml());
        }
        public static GeographyStatisticsSerializable FromXml(string xml)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(GeographyStatisticsSerializable));

            MemoryStream stream = new MemoryStream();

            byte[] xmlBytes = Encoding.Default.GetBytes(xml);
            stream.Write(xmlBytes, 0, xmlBytes.Length);

            stream.Position = 0;
            GeographyStatisticsSerializable result = (GeographyStatisticsSerializable)serializer.Deserialize(stream);

            stream.Close();

            return(result);
        }