Yengine: use using...

This commit is contained in:
UbitUmarov
2018-11-20 23:07:14 +00:00
parent 3e5ca6efd6
commit fb0c8036f0
2 changed files with 14 additions and 10 deletions

View File

@@ -87,10 +87,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine
CheckRunLockInvariants(true);
// Get copy of script globals and stack in relocateable form.
MemoryStream snapshotStream = new MemoryStream();
MigrateOutEventHandler(snapshotStream);
Byte[] snapshotBytes = snapshotStream.ToArray();
snapshotStream.Close();
Byte[] snapshotBytes;
using (MemoryStream snapshotStream = new MemoryStream())
{
MigrateOutEventHandler(snapshotStream);
snapshotBytes = snapshotStream.ToArray();
}
string snapshotString = Convert.ToBase64String(snapshotBytes);
XmlElement snapshotN = doc.CreateElement("", "Snapshot", "");
snapshotN.AppendChild(doc.CreateTextNode(snapshotString));
@@ -180,11 +183,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine
// scriptStateN represents the contents of the .state file so
// write the .state file while we are here.
FileStream fs = File.Create(m_StateFileName);
StreamWriter sw = new StreamWriter(fs);
sw.Write(scriptStateN.OuterXml);
sw.Close();
fs.Close();
using(FileStream fs = File.Create(m_StateFileName))
{
using(StreamWriter sw = new StreamWriter(fs))
sw.Write(scriptStateN.OuterXml);
}
return scriptStateN;
}