File tree 2 files changed +35
-2
lines changed
2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 7
7
using System . Linq ;
8
8
using System . Xml ;
9
9
using System . Xml . Serialization ;
10
- using Newtonsoft . Json . Linq ;
10
+
11
+ using Low_Code_App_Editor_1 . Xml ;
12
+
13
+ using Newtonsoft . Json . Linq ;
11
14
12
15
public static class Extensions
13
16
{
@@ -107,7 +110,7 @@ public static class XmlConvert
107
110
public static string SerializeObject < T > ( T obj )
108
111
{
109
112
XmlSerializer serializer = new XmlSerializer ( typeof ( T ) ) ;
110
- using ( var sww = new StringWriter ( ) )
113
+ using ( var sww = new StringWriterEncoded ( ) )
111
114
{
112
115
using ( XmlWriter writer = new XmlTextWriter ( sww ) { Formatting = System . Xml . Formatting . Indented } )
113
116
{
Original file line number Diff line number Diff line change
1
+ namespace Low_Code_App_Editor_1 . Xml
2
+ {
3
+ using System . IO ;
4
+ using System . Text ;
5
+
6
+ /// <summary>
7
+ /// A StringWriter where you can specify the encoding.
8
+ /// </summary>
9
+ public sealed class StringWriterEncoded : StringWriter
10
+ {
11
+ private readonly Encoding encoding ;
12
+
13
+ /// <summary>
14
+ /// Initializes a new instance of the <see cref="StringWriterEncoded"/> class, with UTF-8 as encoding.
15
+ /// </summary>
16
+ public StringWriterEncoded ( ) : this ( Encoding . UTF8 ) { }
17
+
18
+ /// <summary>
19
+ /// Initializes a new instance of the <see cref="StringWriterEncoded"/> class, with the specified encoding.
20
+ /// </summary>
21
+ /// <param name="encoding"></param>
22
+ public StringWriterEncoded ( Encoding encoding )
23
+ {
24
+ this . encoding = encoding ;
25
+ }
26
+
27
+ /// <inheritdoc/>
28
+ public override Encoding Encoding => encoding ;
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments