mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Added serializable project, references are now immutable.
This commit is contained in:
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user