Exemple #1
0
 /// <summary>
 /// Converts an instance of <see cref="GeoObject"/> to a GeoJSON representation.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     using MemoryStream stream   = new MemoryStream();
     using Utf8JsonWriter writer = new Utf8JsonWriter(stream);
     GeoJsonConverter.Write(writer, this);
     writer.Flush();
     return(Encoding.UTF8.GetString(stream.ToArray()));
 }
        /// <summary>
        /// Converts an instance of <see cref="GeoObject"/> to a GeoJSON representation.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            if (_serialized == null)
            {
                using MemoryStream stream   = new MemoryStream();
                using Utf8JsonWriter writer = new Utf8JsonWriter(stream);
                GeoJsonConverter.Write(writer, this);
                _serialized = Encoding.UTF8.GetString(stream.ToArray());
            }

            return(_serialized);
        }
Exemple #3
0
        /// <summary>
        /// Serializes this instance using the provided <see cref="Utf8JsonWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="Utf8JsonWriter"/> to write to.</param>
#pragma warning disable AZC0014 // do not expose Json types in public APIs
        public void WriteTo(Utf8JsonWriter writer)
#pragma warning restore AZC0014
        {
            Argument.AssertNotNull(writer, nameof(writer));
            GeoJsonConverter.Write(writer, this);
        }