Ejemplo n.º 1
0
        public LoadResult Load(string filename, bool autoBackup = false)
        {
            LoadResult result = LoadResult.Success;

            _fileInfo = new FileInfo(filename);
            _entries  = null;

            if (_fileInfo.Exists)
            {
                _gmml = GMML.Load(_fileInfo.FullName);

                string backupFilePath = _fileInfo.FullName + ".bak";
                if (File.Exists(backupFilePath))
                {
                    _gmmlBackup = GMML.Load(backupFilePath);
                }
                else if (autoBackup || MessageBox.Show("Would you like to create a backup of " + _fileInfo.Name + "?\r\nA backup allows the Original text box to display the source text before edits were made.", "Create Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    File.Copy(_fileInfo.FullName, backupFilePath);
                    _gmmlBackup = GMML.Load(backupFilePath);
                }
                else
                {
                    _gmmlBackup = null;
                }
            }
            else
            {
                result = LoadResult.FileNotFound;
            }

            return(result);
        }
Ejemplo n.º 2
0
        public bool Identify(string filename)
        {
            bool result = true;

            try
            {
                GMML.Load(filename);
            }
            catch (Exception)
            {
                result = false;
            }

            return(result);
        }
Ejemplo n.º 3
0
        public static GMML Load(string filename)
        {
            try
            {
                XmlReaderSettings xmlSettings = new XmlReaderSettings();
                xmlSettings.CheckCharacters = false;

                using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    GMML gmm = (GMML) new XmlSerializer(typeof(GMML)).Deserialize(XmlReader.Create(fs, xmlSettings));
                    return(gmm);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }