@@ -9,27 +9,27 @@ namespace ServiceStack.Text
9
9
{
10
10
public class XmlSerializer
11
11
{
12
- private static readonly XmlWriterSettings XWSettings = new XmlWriterSettings ( ) ;
13
- private static readonly XmlReaderSettings XRSettings = new XmlReaderSettings ( ) ;
12
+ public static readonly XmlWriterSettings XmlWriterSettings = new XmlWriterSettings ( ) ;
13
+ public static readonly XmlReaderSettings XmlReaderSettings = new XmlReaderSettings ( ) ;
14
14
15
15
public static XmlSerializer Instance = new XmlSerializer ( ) ;
16
16
17
17
public XmlSerializer ( bool omitXmlDeclaration = false , int maxCharsInDocument = 1024 * 1024 )
18
18
{
19
- XWSettings . Encoding = PclExport . Instance . GetUTF8Encoding ( false ) ;
20
- XWSettings . OmitXmlDeclaration = omitXmlDeclaration ;
21
- XRSettings . MaxCharactersInDocument = maxCharsInDocument ;
19
+ XmlWriterSettings . Encoding = PclExport . Instance . GetUTF8Encoding ( false ) ;
20
+ XmlWriterSettings . OmitXmlDeclaration = omitXmlDeclaration ;
21
+ XmlReaderSettings . MaxCharactersInDocument = maxCharsInDocument ;
22
22
23
23
//Prevent XML bombs by default: https://msdn.microsoft.com/en-us/magazine/ee335713.aspx
24
- XRSettings . DtdProcessing = DtdProcessing . Prohibit ;
24
+ XmlReaderSettings . DtdProcessing = DtdProcessing . Prohibit ;
25
25
}
26
26
27
27
private static object Deserialize ( string xml , Type type )
28
28
{
29
29
try
30
30
{
31
31
var stringReader = new StringReader ( xml ) ;
32
- using ( var reader = XmlReader . Create ( stringReader , XRSettings ) )
32
+ using ( var reader = XmlReader . Create ( stringReader , XmlReaderSettings ) )
33
33
{
34
34
var serializer = new DataContractSerializer ( type ) ;
35
35
return serializer . ReadObject ( reader ) ;
@@ -76,7 +76,7 @@ public static string SerializeToString<T>(T from)
76
76
{
77
77
using ( var ms = MemoryStreamFactory . GetStream ( ) )
78
78
{
79
- using ( var xw = XmlWriter . Create ( ms , XWSettings ) )
79
+ using ( var xw = XmlWriter . Create ( ms , XmlWriterSettings ) )
80
80
{
81
81
var serializer = new DataContractSerializer ( from . GetType ( ) ) ;
82
82
serializer . WriteObject ( xw , from ) ;
@@ -97,7 +97,7 @@ public static void SerializeToWriter<T>(T value, TextWriter writer)
97
97
{
98
98
try
99
99
{
100
- using ( var xw = XmlWriter . Create ( writer , XWSettings ) )
100
+ using ( var xw = XmlWriter . Create ( writer , XmlWriterSettings ) )
101
101
{
102
102
var serializer = new DataContractSerializer ( value . GetType ( ) ) ;
103
103
serializer . WriteObject ( xw , value ) ;
@@ -112,7 +112,7 @@ public static void SerializeToWriter<T>(T value, TextWriter writer)
112
112
public static void SerializeToStream ( object obj , Stream stream )
113
113
{
114
114
if ( obj == null ) return ;
115
- using ( var xw = XmlWriter . Create ( stream , XWSettings ) )
115
+ using ( var xw = XmlWriter . Create ( stream , XmlWriterSettings ) )
116
116
{
117
117
var serializer = new DataContractSerializer ( obj . GetType ( ) ) ;
118
118
serializer . WriteObject ( xw , obj ) ;
0 commit comments