2014-08-16 14:09:08 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2014-08-30 07:24:01 +00:00
|
|
|
|
using System.IO;
|
2014-08-16 14:09:08 +00:00
|
|
|
|
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;
|
2014-08-16 14:09:08 +00:00
|
|
|
|
|
|
|
|
|
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
|
2014-08-16 14:09:08 +00:00
|
|
|
|
{
|
|
|
|
|
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-16 14:09:08 +00:00
|
|
|
|
|
2014-08-30 07:24:01 +00:00
|
|
|
|
return Reference.StoragePath;
|
2014-08-16 14:09:08 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2014-08-30 07:24:01 +00:00
|
|
|
|
Reference = new Reference(value, ProjectPath);
|
2014-08-16 14:09:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the path of the reference
|
|
|
|
|
/// </summary>
|
2014-08-30 07:24:01 +00:00
|
|
|
|
[XmlElement("projectPath")]
|
|
|
|
|
public string ProjectPath
|
2014-08-16 14:09:08 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2014-08-30 07:24:01 +00:00
|
|
|
|
return Reference.ProjectPath;
|
2014-08-16 14:09:08 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2014-08-30 07:24:01 +00:00
|
|
|
|
Reference = new Reference(StoragePath, value);
|
2014-08-16 14:09:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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>
|
2014-08-16 14:09:08 +00:00
|
|
|
|
public SerializableReference(Reference reference)
|
|
|
|
|
{
|
|
|
|
|
Reference = reference;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|