From efb2a936adfdad70ef414256997f2d2b2bc41ec4 Mon Sep 17 00:00:00 2001 From: Russ Cam Date: Tue, 11 Jun 2019 12:02:07 +1000 Subject: [PATCH] Add overloads of SerializeToString and SerializeToBytes (#3809) This commit adds method overloads of SerializeToString and SerializeToBytes that accept an IMemoryStreamFactory as a non-optional parameter, and reinstates methods that do not take an IMemoryStreamFactory. This will make upgrading from 6.x to 7.x easier for those that make use of SerializeToString. Closes #3771 --- .../ElasticsearchSerializerExtensions.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Elasticsearch.Net/Serialization/ElasticsearchSerializerExtensions.cs b/src/Elasticsearch.Net/Serialization/ElasticsearchSerializerExtensions.cs index 1948f5b43a2..6d86b0b0cb4 100644 --- a/src/Elasticsearch.Net/Serialization/ElasticsearchSerializerExtensions.cs +++ b/src/Elasticsearch.Net/Serialization/ElasticsearchSerializerExtensions.cs @@ -8,7 +8,13 @@ public static class ElasticsearchSerializerExtensions public static byte[] SerializeToBytes( this IElasticsearchSerializer serializer, T data, - IMemoryStreamFactory memoryStreamFactory = null, + SerializationFormatting formatting = SerializationFormatting.Indented) => + SerializeToBytes(serializer, data, RecyclableMemoryStreamFactory.Default, formatting); + + public static byte[] SerializeToBytes( + this IElasticsearchSerializer serializer, + T data, + IMemoryStreamFactory memoryStreamFactory, SerializationFormatting formatting = SerializationFormatting.Indented ) { @@ -23,7 +29,13 @@ public static byte[] SerializeToBytes( public static string SerializeToString( this IElasticsearchSerializer serializer, T data, - IMemoryStreamFactory memoryStreamFactory = null, + SerializationFormatting formatting = SerializationFormatting.Indented) => + SerializeToString(serializer, data, RecyclableMemoryStreamFactory.Default, formatting); + + public static string SerializeToString( + this IElasticsearchSerializer serializer, + T data, + IMemoryStreamFactory memoryStreamFactory, SerializationFormatting formatting = SerializationFormatting.Indented ) { @@ -34,7 +46,5 @@ public static string SerializeToString( return ms.Utf8String(); } } - - } }