rainmeter-studio/RainmeterStudio.Core/Storage/SerializableReference.cs

82 lines
2.0 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
2014-08-30 07:24:01 +00:00
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using RainmeterStudio.Core.Model;
2014-08-30 07:24:01 +00:00
using RainmeterStudio.Core.Utils;
namespace RainmeterStudio.Core.Storage
{
/// <summary>
/// Represents a reference that can be serialized
/// </summary>
public class SerializableReference
{
/// <summary>
/// Gets or sets the name of the reference
/// </summary>
2014-08-30 07:24:01 +00:00
[XmlElement("storagePath")]
public string StoragePath
{
get
{
2014-08-30 07:24:01 +00:00
// Return only relative paths
if (Path.IsPathRooted(Reference.StoragePath))
{
return PathHelper.GetRelativePath(Reference.StoragePath);
}
2014-08-30 07:24:01 +00:00
return Reference.StoragePath;
}
set
{
2014-08-30 07:24:01 +00:00
Reference = new Reference(value, ProjectPath);
}
}
/// <summary>
/// Gets or sets the path of the reference
/// </summary>
2014-08-30 07:24:01 +00:00
[XmlElement("projectPath")]
public string ProjectPath
{
get
{
2014-08-30 07:24:01 +00:00
return Reference.ProjectPath;
}
set
{
2014-08-30 07:24:01 +00:00
Reference = new Reference(StoragePath, value);
}
}
/// <summary>
/// Gets or sets the (immutable) reference
/// </summary>
[XmlIgnore]
public Reference Reference
{
get;
set;
}
/// <summary>
/// Initializes this serializable reference
/// </summary>
public SerializableReference()
{
}
2014-08-30 07:24:01 +00:00
/// <summary>
/// Initializes this serializable reference
/// </summary>
/// <param name="reference">Reference to use</param>
public SerializableReference(Reference reference)
{
Reference = reference;
}
}
}