11using System ;
2- using System . Text . Json ;
32using Microsoft . Extensions . DependencyInjection ;
3+ using Microsoft . Extensions . Options ;
44using Shuttle . Core . Contract ;
55
66namespace Shuttle . Core . Serialization
@@ -17,25 +17,7 @@ public static IServiceCollection AddJsonSerializer(this IServiceCollection servi
1717
1818 services . AddSingleton < ISerializer , JsonSerializer > ( ) ;
1919
20- services . AddOptions < JsonSerializerOptions > ( ) . Configure ( options =>
21- {
22- options . AllowTrailingCommas = jsonSerializerBuilder . Options . AllowTrailingCommas ;
23- options . DefaultBufferSize = jsonSerializerBuilder . Options . DefaultBufferSize ;
24- options . DefaultIgnoreCondition = jsonSerializerBuilder . Options . DefaultIgnoreCondition ;
25- options . DictionaryKeyPolicy = jsonSerializerBuilder . Options . DictionaryKeyPolicy ;
26- options . Encoder = jsonSerializerBuilder . Options . Encoder ;
27- options . IgnoreReadOnlyFields = jsonSerializerBuilder . Options . IgnoreReadOnlyFields ;
28- options . IncludeFields = jsonSerializerBuilder . Options . IncludeFields ;
29- options . IgnoreReadOnlyProperties = jsonSerializerBuilder . Options . IgnoreReadOnlyProperties ;
30- options . MaxDepth = jsonSerializerBuilder . Options . MaxDepth ;
31- options . NumberHandling = jsonSerializerBuilder . Options . NumberHandling ;
32- options . PropertyNameCaseInsensitive = jsonSerializerBuilder . Options . PropertyNameCaseInsensitive ;
33- options . PropertyNamingPolicy = jsonSerializerBuilder . Options . PropertyNamingPolicy ;
34- options . ReadCommentHandling = jsonSerializerBuilder . Options . ReadCommentHandling ;
35- options . ReferenceHandler = jsonSerializerBuilder . Options . ReferenceHandler ;
36- options . UnknownTypeHandling = jsonSerializerBuilder . Options . UnknownTypeHandling ;
37- options . WriteIndented = jsonSerializerBuilder . Options . WriteIndented ;
38- } ) ;
20+ services . AddSingleton ( Options . Create ( jsonSerializerBuilder . Options ) ) ;
3921
4022 return services ;
4123 }
@@ -50,27 +32,7 @@ public static IServiceCollection AddXmlSerializer(this IServiceCollection servic
5032
5133 services . AddSingleton < ISerializer , XmlSerializer > ( ) ;
5234
53- services . AddOptions < XmlSerializerOptions > ( ) . Configure ( options =>
54- {
55- options . Indent = xmlSerializerBuilder . Options . Indent ;
56- options . OmitXmlDeclaration = xmlSerializerBuilder . Options . OmitXmlDeclaration ;
57- options . Encoding = xmlSerializerBuilder . Options . Encoding ;
58- options . NewLineHandling = xmlSerializerBuilder . Options . NewLineHandling ;
59- options . NewLineChars = xmlSerializerBuilder . Options . NewLineChars ;
60- options . NewLineOnAttributes = xmlSerializerBuilder . Options . NewLineOnAttributes ;
61- options . CheckCharacters = xmlSerializerBuilder . Options . CheckCharacters ;
62- options . ConformanceLevel = xmlSerializerBuilder . Options . ConformanceLevel ;
63- options . CloseOutput = xmlSerializerBuilder . Options . CloseOutput ;
64- options . IndentChars = xmlSerializerBuilder . Options . IndentChars ;
65- options . NamespaceHandling = xmlSerializerBuilder . Options . NamespaceHandling ;
66- options . DoNotEscapeUriAttributes = xmlSerializerBuilder . Options . DoNotEscapeUriAttributes ;
67- options . WriteEndDocumentOnClose = xmlSerializerBuilder . Options . WriteEndDocumentOnClose ;
68- options . MaxArrayLength = xmlSerializerBuilder . Options . MaxArrayLength ;
69- options . MaxStringContentLength = xmlSerializerBuilder . Options . MaxStringContentLength ;
70- options . MaxNameTableCharCount = xmlSerializerBuilder . Options . MaxNameTableCharCount ;
71- options . MaxBytesPerRead = xmlSerializerBuilder . Options . MaxBytesPerRead ;
72- options . MaxDepth = xmlSerializerBuilder . Options . MaxDepth ;
73- } ) ;
35+ services . AddSingleton ( Options . Create ( xmlSerializerBuilder . Options ) ) ;
7436
7537 return services ;
7638 }
0 commit comments