using System.Net; namespace MessagePack.Formatters { /// /// Serialization of an to and from . /// [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public class IPAddressFormatter : IMessagePackFormatter { /// public IPAddress Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.IsNil) return null; byte[] bytes = options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); return new IPAddress(bytes); } /// public void Serialize(ref MessagePackWriter writer, IPAddress value, MessagePackSerializerOptions options) { if (value == null) { writer.WriteNil(); return; } byte[] bytes = value.GetAddressBytes(); options.Resolver.GetFormatterWithVerify().Serialize(ref writer, bytes, options); } } }