Skip to content

Commit

Permalink
Add overloads of SerializeToString and SerializeToBytes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
russcam committed Jun 11, 2019
1 parent 70f87f3 commit eec374d
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ public static class ElasticsearchSerializerExtensions
public static byte[] SerializeToBytes<T>(
this IElasticsearchSerializer serializer,
T data,
IMemoryStreamFactory memoryStreamFactory = null,
SerializationFormatting formatting = SerializationFormatting.Indented) =>
SerializeToBytes(serializer, data, RecyclableMemoryStreamFactory.Default, formatting);

public static byte[] SerializeToBytes<T>(
this IElasticsearchSerializer serializer,
T data,
IMemoryStreamFactory memoryStreamFactory,
SerializationFormatting formatting = SerializationFormatting.Indented
)
{
Expand All @@ -23,7 +29,13 @@ public static byte[] SerializeToBytes<T>(
public static string SerializeToString<T>(
this IElasticsearchSerializer serializer,
T data,
IMemoryStreamFactory memoryStreamFactory = null,
SerializationFormatting formatting = SerializationFormatting.Indented) =>
SerializeToString(serializer, data, RecyclableMemoryStreamFactory.Default, formatting);

public static string SerializeToString<T>(
this IElasticsearchSerializer serializer,
T data,
IMemoryStreamFactory memoryStreamFactory,
SerializationFormatting formatting = SerializationFormatting.Indented
)
{
Expand All @@ -34,7 +46,5 @@ public static string SerializeToString<T>(
return ms.Utf8String();
}
}


}
}

0 comments on commit eec374d

Please sign in to comment.