Beispiel #1
0
        /// <summary>
        /// Function to save the editor file.
        /// </summary>
        /// <param name="path">Path to the new file.</param>
        /// <param name="plugIn">The plug-in used to save the file.</param>
        public static void Save(string path, FileWriterPlugIn plugIn)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentException(APIResources.GOREDIT_ERR_PARAMETER_MUST_NOT_BE_EMPTY, "path");
            }

            // We don't have a writer plug-in, at this point, that's not good.
            if (plugIn == null)
            {
                throw new IOException(string.Format(APIResources.GOREDIT_ERR_NO_WRITER_PLUGIN, path));
            }

            // Write the meta data file to the file system.
            EditorMetaDataFile.Save();

            // Write the file.
            if (!plugIn.Save(path))
            {
                return;
            }

            Filename = Path.GetFileName(path);
            FilePath = path;

            // Remove all changed items.
            FileChanged = false;
        }
Beispiel #2
0
        /// <summary>
        /// Function to save the current content.
        /// </summary>
        /// <param name="persistMetaData">[Optional] TRUE to persist the meta data for the file, FALSE to leave it.</param>
        public static void Save(bool persistMetaData = true)
        {
            if ((Current == null) ||
                (ContentFile == null))
            {
                return;
            }

            // Write the content out to the scratch file system.
            using (var contentStream = ContentFile.OpenStream(true))
            {
                Current.Persist(contentStream);
            }

            // Save any metadata.
            if (!persistMetaData)
            {
                return;
            }

            EditorMetaDataFile.Save();

            if (ContentSaved == null)
            {
                return;
            }

            ContentSaved();
        }