using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Xml.Serialization; using RainmeterStudio.Core; using RainmeterStudio.Core.Model; using RainmeterStudio.Core.Storage; using RainmeterStudio.Storage; namespace RainmeterStudio.Editor.ProjectEditor { /// /// Project storage, loads and saves project files /// [PluginExport] public class ProjectDocumentStorage : IDocumentStorage { /// /// Reads the project as a ProjectDocument. /// Use Load to get only the Project. /// /// Path to project file /// A project document public IDocument ReadDocument(string path) { Project project = ProjectStorage.Read(path); var document = new ProjectDocument(project); document.Reference = new Reference(Path.GetFileName(path), path, ReferenceTargetKind.Project); return document; } /// /// Writes a project document to file /// /// /// public void WriteDocument(IDocument document, string path) { var projectDocument = (ProjectDocument)document; ProjectStorage.Write(projectDocument.Project, path); } /// /// Returns true if the file is a project storage /// /// Path to file /// True if the file can be read by this storage public bool CanReadDocument(string path) { return (Path.GetExtension(path) == ".rsproj"); } /// /// Returns true if this can write specified document type /// /// Document type /// True if document can be written by this storage public bool CanWriteDocument(Type documentType) { return documentType.Equals(typeof(ProjectDocument)); } } }