Skip to content

Commit efb2a93

Browse files
authored
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
1 parent d835462 commit efb2a93

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/Elasticsearch.Net/Serialization/ElasticsearchSerializerExtensions.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ public static class ElasticsearchSerializerExtensions
88
public static byte[] SerializeToBytes<T>(
99
this IElasticsearchSerializer serializer,
1010
T data,
11-
IMemoryStreamFactory memoryStreamFactory = null,
11+
SerializationFormatting formatting = SerializationFormatting.Indented) =>
12+
SerializeToBytes(serializer, data, RecyclableMemoryStreamFactory.Default, formatting);
13+
14+
public static byte[] SerializeToBytes<T>(
15+
this IElasticsearchSerializer serializer,
16+
T data,
17+
IMemoryStreamFactory memoryStreamFactory,
1218
SerializationFormatting formatting = SerializationFormatting.Indented
1319
)
1420
{
@@ -23,7 +29,13 @@ public static byte[] SerializeToBytes<T>(
2329
public static string SerializeToString<T>(
2430
this IElasticsearchSerializer serializer,
2531
T data,
26-
IMemoryStreamFactory memoryStreamFactory = null,
32+
SerializationFormatting formatting = SerializationFormatting.Indented) =>
33+
SerializeToString(serializer, data, RecyclableMemoryStreamFactory.Default, formatting);
34+
35+
public static string SerializeToString<T>(
36+
this IElasticsearchSerializer serializer,
37+
T data,
38+
IMemoryStreamFactory memoryStreamFactory,
2739
SerializationFormatting formatting = SerializationFormatting.Indented
2840
)
2941
{
@@ -34,7 +46,5 @@ public static string SerializeToString<T>(
3446
return ms.Utf8String();
3547
}
3648
}
37-
38-
3949
}
4050
}

0 commit comments

Comments
 (0)