|
6 | 6 |
|
7 | 7 | namespace IoTSharp.EntityFrameworkCore.MongoDB.Storage.Internal;
|
8 | 8 |
|
9 |
| -/// <summary> |
10 |
| -/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to |
11 |
| -/// the same compatibility standards as public APIs. It may be changed or removed without notice in |
12 |
| -/// any release. You should only use it directly in your code with extreme caution and knowing that |
13 |
| -/// doing so can result in application failures when updating to a new Entity Framework Core release. |
14 |
| -/// </summary> |
15 |
| -public class JsonCosmosDBSerializer : CosmosSerializer |
16 |
| -{ |
17 |
| - private static readonly Encoding DefaultEncoding = new UTF8Encoding(false, true); |
18 |
| - |
19 |
| - /// <inheritdoc /> |
20 |
| - public override T FromStream<T>(Stream stream) |
21 |
| - { |
22 |
| - using (stream) |
23 |
| - { |
24 |
| - if (typeof(Stream).IsAssignableFrom(typeof(T))) |
25 |
| - { |
26 |
| - return (T)(object)stream; |
27 |
| - } |
28 |
| - |
29 |
| - using var streamReader = new StreamReader(stream); |
30 |
| - using var jsonTextReader = new JsonTextReader(streamReader); |
31 |
| - return GetSerializer().Deserialize<T>(jsonTextReader); |
32 |
| - } |
33 |
| - } |
34 |
| - |
35 |
| - /// <inheritdoc /> |
36 |
| - public override Stream ToStream<T>(T input) |
37 |
| - { |
38 |
| - var streamPayload = new MemoryStream(); |
39 |
| - using (var streamWriter = new StreamWriter(streamPayload, encoding: DefaultEncoding, bufferSize: 1024, leaveOpen: true)) |
40 |
| - { |
41 |
| - using var jsonTextWriter = new JsonTextWriter(streamWriter); |
42 |
| - jsonTextWriter.Formatting = Formatting.None; |
43 |
| - GetSerializer().Serialize(jsonTextWriter, input); |
44 |
| - jsonTextWriter.Flush(); |
45 |
| - streamWriter.Flush(); |
46 |
| - } |
47 |
| - |
48 |
| - streamPayload.Position = 0; |
49 |
| - return streamPayload; |
50 |
| - } |
51 |
| - |
52 |
| - private static JsonSerializer GetSerializer() |
53 |
| - => MongoDBClientWrapper.Serializer; |
54 |
| -} |
| 9 | +///// <summary> |
| 10 | +///// This is an internal API that supports the Entity Framework Core infrastructure and not subject to |
| 11 | +///// the same compatibility standards as public APIs. It may be changed or removed without notice in |
| 12 | +///// any release. You should only use it directly in your code with extreme caution and knowing that |
| 13 | +///// doing so can result in application failures when updating to a new Entity Framework Core release. |
| 14 | +///// </summary> |
| 15 | +//public class JsonCosmosDBSerializer : MongoDBRefSerializer |
| 16 | +//{ |
| 17 | +// private static readonly Encoding DefaultEncoding = new UTF8Encoding(false, true); |
| 18 | + |
| 19 | + |
| 20 | +// /// <inheritdoc /> |
| 21 | +// public override T FromStream<T>(Stream stream) |
| 22 | +// { |
| 23 | +// using (stream) |
| 24 | +// { |
| 25 | +// if (typeof(Stream).IsAssignableFrom(typeof(T))) |
| 26 | +// { |
| 27 | +// return (T)(object)stream; |
| 28 | +// } |
| 29 | + |
| 30 | +// using var streamReader = new StreamReader(stream); |
| 31 | +// using var jsonTextReader = new JsonTextReader(streamReader); |
| 32 | +// return GetSerializer().Deserialize<T>(jsonTextReader); |
| 33 | +// } |
| 34 | +// } |
| 35 | + |
| 36 | +// /// <inheritdoc /> |
| 37 | +// public override Stream ToStream<T>(T input) |
| 38 | +// { |
| 39 | +// var streamPayload = new MemoryStream(); |
| 40 | +// using (var streamWriter = new StreamWriter(streamPayload, encoding: DefaultEncoding, bufferSize: 1024, leaveOpen: true)) |
| 41 | +// { |
| 42 | +// using var jsonTextWriter = new JsonTextWriter(streamWriter); |
| 43 | +// jsonTextWriter.Formatting = Formatting.None; |
| 44 | +// GetSerializer().Serialize(jsonTextWriter, input); |
| 45 | +// jsonTextWriter.Flush(); |
| 46 | +// streamWriter.Flush(); |
| 47 | +// } |
| 48 | + |
| 49 | +// streamPayload.Position = 0; |
| 50 | +// return streamPayload; |
| 51 | +// } |
| 52 | + |
| 53 | +// private static JsonSerializer GetSerializer() |
| 54 | +// => MongoDBClientWrapper.Serializer; |
| 55 | +//} |
0 commit comments