private static string GetStyleXml(Element e)
        {
            var kml = KmlFile.Create(e, true);
            // we must to use NotCloseableMemoryStream because kml.Save pretend to close the stream we provide, but we do not want that.
            var ms = new NotCloseableMemoryStream();

            try
            {
                kml.Save(ms);

                ms.Seek(0, SeekOrigin.Begin);

                using (var reader = new StreamReader(ms))
                    return(reader.ReadToEnd());
            }
            finally
            {
                // we can't just use the Dispose method because it does not call its virtual overload
                ms.ForceDispose();
            }
        }
Пример #2
0
        private static string GetStyleXml(Element e)
        {
            var kml = KmlFile.Create(e, true);
            // we must to use NotCloseableMemoryStream because kml.Save pretend to close the stream we provide, but we do not want that.
            var ms = new NotCloseableMemoryStream();
            try
            {
                kml.Save(ms);

                ms.Seek(0, SeekOrigin.Begin);

                using (var reader = new StreamReader(ms))
                    return reader.ReadToEnd();
            }
            finally
            {
                // we can't just use the Dispose method because it does not call its virtual overload
                ms.ForceDispose();
            }
        }