示例#1
0
        /// <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);
        }
示例#2
0
        public override void Clone(SaveableData Data)
        {
            SaveablePreset preset = Data as SaveablePreset;

            if (preset != null)
            {
                _name       = preset.Name;
                _presetType = preset.PresetType;
            }
        }
示例#3
0
 /// <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)
 {
 }