93 lines
2 KiB
C#
93 lines
2 KiB
C#
using System;
|
|
using JD.Kernel.StaticHelpers;
|
|
|
|
namespace JD.TeaBoxAddinSystem.Addins.Description.Conditions
|
|
{
|
|
/// <summary>
|
|
/// Describes a condition and its target.
|
|
/// </summary>
|
|
public class ConditionInfo : AddinObject
|
|
{
|
|
#region Variables
|
|
|
|
private readonly Condition m_condition;
|
|
private string m_target;
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
/// <summary>
|
|
/// Constructor.
|
|
/// </summary>
|
|
/// <param name="condition"></param>
|
|
public ConditionInfo(Condition condition)
|
|
{
|
|
Throw.IfNull(condition, "condition");
|
|
m_condition = condition;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor.
|
|
/// </summary>
|
|
/// <param name="condition"></param>
|
|
/// <param name="target"></param>
|
|
public ConditionInfo(Condition condition, string target)
|
|
: this(condition)
|
|
{
|
|
Target = target;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
/// <summary>
|
|
/// Condition.
|
|
/// </summary>
|
|
public Condition Condition
|
|
{
|
|
get
|
|
{
|
|
return m_condition;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Target to apply the condition to.
|
|
/// </summary>
|
|
public string Target
|
|
{
|
|
get
|
|
{
|
|
return m_target;
|
|
}
|
|
set
|
|
{
|
|
ThrowIfLoaded();
|
|
m_target = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
internal override void OnModuleChanged(EventArgs e)
|
|
{
|
|
Condition.Module = Module;
|
|
base.OnModuleChanged(e);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Overriden.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public override string ToString()
|
|
{
|
|
return $"[ConditionInfo: Condition={Condition} Target={(string.IsNullOrEmpty(Target) ? "None" : Target)}]";
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|