muddesigner/MudEngine/FileSystem/XmlSerialization.cs
Scionwest_cp dc311f5aa5 Added MudEngine Project to the Solution. I will slowly be moving the MudDesigner.MudEngine classes out of the Mud Designer Solution and into it's own.
Currently the Mud Designer still contains the old MudEngine classes until migration has been completed.
2010-07-15 18:53:38 -07:00

40 lines
1.1 KiB
C#

//Microsoft .NET Framework
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;
namespace MudEngine.FileSystem
{
internal class XmlSerialization
{
internal static void Save(string Filename, object o)
{
Stream stream = File.Create(Filename);
XmlSerializer serializer = new XmlSerializer(o.GetType());
serializer.Serialize(stream, o);
stream.Close();
}
/// <summary>
/// Loads an item via Xml Deserialization
/// </summary>
/// <param name="Filename">The Xml document to deserialize.</param>
/// <returns></returns>
internal static object Load(string Filename, object o)
{
Stream stream = File.OpenRead(Filename);
object obj = new object();
XmlSerializer serializer = new XmlSerializer(o.GetType());
obj = (object)serializer.Deserialize(stream);
stream.Close();
return obj;
}
}
}