/// <summary> /// Deserialize the Data to a file, Always overwriting /// </summary> /// <param name="inPath">Path to load the file from</param> /// <returns>True in case of Success</returns> public bool Load(string inPath) { FileInfo ThisFileInfo = new FileInfo(inPath); if (ThisFileInfo.Exists) { XmlSerializer thisSaveable = new XmlSerializer(GetType()); FileStream stream = ThisFileInfo.OpenRead(); try { SaveableData loaded = (SaveableData)thisSaveable.Deserialize(stream); Clone(loaded); stream.Close(); return(true); } catch (Exception) { if (stream != null) { stream.Close(); } } } return(false); }
public override void Clone(SaveableData Data) { SaveablePreset preset = Data as SaveablePreset; if (preset != null) { _name = preset.Name; _presetType = preset.PresetType; } }
/// <summary> /// Clone the values from an instance to another /// Classes that inherits from SaveAbleData must override this and read values from 'Data' /// </summary> /// <param name="Data">Data to get the values from</param> public virtual void Clone(SaveableData Data) { }