64 lines
1.7 KiB
Plaintext
64 lines
1.7 KiB
Plaintext
|
|
using DTS.Common.Interface.Tags;
|
||
|
|
using System.Data;
|
||
|
|
|
||
|
|
namespace DTS.Common.Classes.Tags
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// describes a database record for a tag
|
||
|
|
/// <inheritdoc cref="ITag"/>
|
||
|
|
/// </summary>
|
||
|
|
/// <summary>
|
||
|
|
/// represents a single tag, which is composed of an ID and a string of text
|
||
|
|
/// we don't currently let you obsolete, delete, or edit tags, just add
|
||
|
|
/// </summary>
|
||
|
|
public class Tag : Base.BasePropertyChanged, ITag
|
||
|
|
{
|
||
|
|
public Tag(string tagText, int tagId)
|
||
|
|
{
|
||
|
|
ID = tagId;
|
||
|
|
Text = tagText;
|
||
|
|
IsObsolete = false;
|
||
|
|
}
|
||
|
|
public const int INVALID_ID = -1;
|
||
|
|
|
||
|
|
private int _id;
|
||
|
|
public int ID
|
||
|
|
{
|
||
|
|
get => _id;
|
||
|
|
set => SetProperty(ref _id, value, "ID");
|
||
|
|
}
|
||
|
|
|
||
|
|
private string _text = "";
|
||
|
|
public string Text
|
||
|
|
{
|
||
|
|
get => _text;
|
||
|
|
set => SetProperty(ref _text, value, "Text");
|
||
|
|
}
|
||
|
|
|
||
|
|
private bool _isObsolete = false;
|
||
|
|
public bool IsObsolete
|
||
|
|
{
|
||
|
|
get => _isObsolete;
|
||
|
|
set => SetProperty(ref _isObsolete, value, "IsObsolete");
|
||
|
|
}
|
||
|
|
public Tag(Tag copy)
|
||
|
|
{
|
||
|
|
ID = copy.ID;
|
||
|
|
Text = copy.Text;
|
||
|
|
IsObsolete = copy.IsObsolete;
|
||
|
|
}
|
||
|
|
|
||
|
|
public Tag(IDataReader reader)
|
||
|
|
{
|
||
|
|
ID = Utility.GetInt(reader, "TagId");
|
||
|
|
IsObsolete = Utility.GetBool(reader, "Obsolete");
|
||
|
|
Text = Utility.GetString(reader, "TagText");
|
||
|
|
}
|
||
|
|
public Tag() { }
|
||
|
|
public object Clone()
|
||
|
|
{
|
||
|
|
return new Tag(this);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|