public override BoxMessage Perform() { string file = null; string path = null; Type type = null; switch (m_DataType) { case BoxDatafile.BoxData: file = "BoxData.xml"; type = typeof(BoxData); break; case BoxDatafile.PropsData: file = "PropsData.xml"; type = typeof(PropsData); break; case BoxDatafile.SpawnData: file = "SpawnData.xml"; type = typeof(SpawnData); break; } path = System.IO.Path.Combine(BoxUtil.BoxFolder, file); object data = BoxUtil.XmlLoad(path, type); if (data == null) { return(new DatafileNotFound()); } else { return(new ReturnDatafile(data)); } }
/// <summary> /// Reads a BoxData object from a file /// </summary> /// <param name="filename">The filename containing the BoxData object</param> /// <returns>The BoxData object read from file, or null if not succesful</returns> public static BoxData Load(string filename) { return(BoxUtil.XmlLoad(filename, typeof(BoxData)) as BoxData); }
/// <summary> /// Loads a PropsData object from an xml file /// </summary> /// <param name="file">The xml file containing the PropsData object</param> /// <returns>The loaded PropsData</returns> public static PropsData Load(string file) { return(BoxUtil.XmlLoad(file, typeof(PropsData)) as PropsData); }