Merge branch 'ubitwork' into avination

avinationmerge
Melanie 2012-07-07 19:18:20 +02:00
commit 6d5693a866
1 changed files with 13 additions and 7 deletions

View File

@ -565,31 +565,37 @@ namespace OpenSim.Region.Framework.Scenes
public string ToXml2() public string ToXml2()
{ {
MemoryStream ms = new MemoryStream(); MemoryStream ms = new MemoryStream(512);
UTF8Encoding enc = new UTF8Encoding(); UTF8Encoding enc = new UTF8Encoding();
XmlTextWriter writer = new XmlTextWriter(ms, null); XmlTextWriter xwriter = new XmlTextWriter(ms, enc);
ToXml2(writer); ToXml2(xwriter);
return enc.GetString(ms.ToArray()); xwriter.Flush();
string s = ms.GetStreamString();
xwriter.Close();
return s;
} }
public static SOPVehicle FromXml2(string text) public static SOPVehicle FromXml2(string text)
{ {
if (text == String.Empty) if (text == String.Empty)
return null; return null;
UTF8Encoding enc = new UTF8Encoding(); UTF8Encoding enc = new UTF8Encoding();
MemoryStream ms = new MemoryStream(enc.GetBytes(text)); MemoryStream ms = new MemoryStream(enc.GetBytes(text));
XmlTextReader reader = new XmlTextReader(ms); XmlTextReader xreader = new XmlTextReader(ms);
SOPVehicle v = new SOPVehicle(); SOPVehicle v = new SOPVehicle();
bool error; bool error;
v.FromXml2(reader, out error); v.FromXml2(xreader, out error);
xreader.Close();
if (error) if (error)
{ {
v = null; v = null;
return null; return null;
} }
return v; return v;
} }