109 lines
2.6 KiB
C#
109 lines
2.6 KiB
C#
using System;
|
|
|
|
namespace JD.TeaBoxAddinSystem.Addins
|
|
{
|
|
/// <summary>
|
|
/// Attribute that is used to signify that the property/field can be deserialized from a string.
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple=false)]
|
|
public class StringPropertyConverterAttribute : Attribute
|
|
{
|
|
#region Variables
|
|
|
|
private readonly string m_name;
|
|
private readonly bool m_required;
|
|
private readonly string m_description;
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
/// <summary>
|
|
/// Constructor.
|
|
/// </summary>
|
|
public StringPropertyConverterAttribute()
|
|
: this(null, false, null)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor.
|
|
/// </summary>
|
|
/// <param name="required"></param>
|
|
public StringPropertyConverterAttribute(bool required)
|
|
: this(null, required, null)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor.
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
public StringPropertyConverterAttribute(string name)
|
|
: this(name, false, null)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor.
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
/// <param name="required"></param>
|
|
public StringPropertyConverterAttribute(string name, bool required)
|
|
: this(name, required, null)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor.
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
/// <param name="required"></param>
|
|
/// <param name="description"></param>
|
|
public StringPropertyConverterAttribute(string name, bool required, string description)
|
|
{
|
|
m_name = name;
|
|
m_required = required;
|
|
m_description = description;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
/// <summary>
|
|
/// Name of the serialized field.
|
|
/// </summary>
|
|
public string Name
|
|
{
|
|
get
|
|
{
|
|
return m_name;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Whether the member with this attribute represents a required field.
|
|
/// </summary>
|
|
public bool Required
|
|
{
|
|
get
|
|
{
|
|
return m_required;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Description.
|
|
/// </summary>
|
|
public string Description
|
|
{
|
|
get
|
|
{
|
|
return m_description;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|