Added serializable project, references are now immutable.

This commit is contained in:
2014-08-16 17:09:08 +03:00
parent 7f525d0d86
commit a3fdc31caa
9 changed files with 326 additions and 136 deletions

View File

@ -176,8 +176,7 @@ namespace RainmeterStudio.Business
storage.Write(path, document);
// Update reference
document.Reference.Name = Path.GetFileName(path);
document.Reference.Path = path;
document.Reference = new Reference(Path.GetFileName(path), path);
// Clear dirty flag
document.IsDirty = false;

View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Xml.Serialization;
using RainmeterStudio.Core.Model;
using RainmeterStudio.Core.Storage;
namespace RainmeterStudio.Storage
{
@ -16,14 +17,14 @@ namespace RainmeterStudio.Storage
var file = File.OpenText(path);
// Deserialize file
var serializer = new XmlSerializer(typeof(Project), new XmlRootAttribute("project"));
Project project = serializer.Deserialize(file) as Project;
var serializer = new XmlSerializer(typeof(SerializableProject), new XmlRootAttribute("project"));
SerializableProject project = serializer.Deserialize(file) as SerializableProject;
if (project != null)
project.Path = path;
// Clean up
file.Close();
return project;
return project.Project;
}
public void Save(string path, Project project)
@ -32,8 +33,9 @@ namespace RainmeterStudio.Storage
var file = File.OpenWrite(path);
// Serialize file
var serializer = new XmlSerializer(typeof(Project), new XmlRootAttribute("project"));
serializer.Serialize(file, project);
var sProject = new SerializableProject(project);
var serializer = new XmlSerializer(typeof(SerializableProject), new XmlRootAttribute("project"));
serializer.Serialize(file, sProject);
// Clean up
file.Close();

View File

@ -28,13 +28,6 @@ namespace RainmeterStudio.UI.ViewModel
{
return Reference.Data.Name;
}
set
{
Reference.Data.Name = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Name"));
}
}
/// <summary>
@ -46,13 +39,6 @@ namespace RainmeterStudio.UI.ViewModel
{
return Reference.Data.Path;
}
set
{
Reference.Data.Path = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Path"));
}
}