diff options
Diffstat (limited to '')
-rw-r--r-- | Common/XmlRpcCS/XmlRpcSerializer.cs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/Common/XmlRpcCS/XmlRpcSerializer.cs b/Common/XmlRpcCS/XmlRpcSerializer.cs index a75770e..b682f69 100644 --- a/Common/XmlRpcCS/XmlRpcSerializer.cs +++ b/Common/XmlRpcCS/XmlRpcSerializer.cs | |||
@@ -31,6 +31,7 @@ namespace Nwc.XmlRpc | |||
31 | using System.Collections; | 31 | using System.Collections; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Xml; | 33 | using System.Xml; |
34 | using System.Text; | ||
34 | 35 | ||
35 | /// <summary>Base class of classes serializing data to XML-RPC's XML format.</summary> | 36 | /// <summary>Base class of classes serializing data to XML-RPC's XML format.</summary> |
36 | /// <remarks>This class handles the basic type conversions like Integer to <i4>. </remarks> | 37 | /// <remarks>This class handles the basic type conversions like Integer to <i4>. </remarks> |
@@ -53,15 +54,22 @@ namespace Nwc.XmlRpc | |||
53 | /// <seealso cref="XmlRpcRequest"/> | 54 | /// <seealso cref="XmlRpcRequest"/> |
54 | public String Serialize(Object obj) | 55 | public String Serialize(Object obj) |
55 | { | 56 | { |
56 | StringWriter strBuf = new StringWriter(); | 57 | using (MemoryStream memStream = new MemoryStream(4096)) |
57 | XmlTextWriter xml = new XmlTextWriter(strBuf); | 58 | { |
58 | xml.Formatting = Formatting.Indented; | 59 | XmlTextWriter xml = new XmlTextWriter(memStream, Encoding.UTF8); |
59 | xml.Indentation = 4; | 60 | xml.Formatting = Formatting.Indented; |
60 | Serialize(xml, obj); | 61 | xml.Indentation = 4; |
61 | xml.Flush(); | 62 | Serialize(xml, obj); |
62 | String returns = strBuf.ToString(); | 63 | xml.Flush(); |
63 | xml.Close(); | 64 | |
64 | return returns; | 65 | byte[] resultBytes = memStream.ToArray(); |
66 | |||
67 | UTF8Encoding encoder = new UTF8Encoding(); | ||
68 | |||
69 | String returns = encoder.GetString( resultBytes, 0, resultBytes.Length ); | ||
70 | xml.Close(); | ||
71 | return returns; | ||
72 | } | ||
65 | } | 73 | } |
66 | 74 | ||
67 | /// <remarks>Serialize the object to the output stream.</remarks> | 75 | /// <remarks>Serialize the object to the output stream.</remarks> |