using RuriLib.ViewModels;
namespace RuriLib.Models
{
///
/// Represents a Key in a KeyChain.
///
public class Key : ViewModelBase
{
private string leftTerm = "";
/// The left-hand term for the comparison.
public string LeftTerm { get { return leftTerm; } set { leftTerm = value; OnPropertyChanged(); } }
private Condition condition = Condition.Contains;
/// The condition of the comparison.
public Condition Condition { get { return condition; } set { condition = value; OnPropertyChanged(); } }
private string rightTerm = "";
/// The right-hand term of the comparison.
public string RightTerm { get { return rightTerm; } set { rightTerm = value; OnPropertyChanged(); } }
///
/// Checks the comparison between left and right member.
///
/// The BotData used for variable replacement.
/// Whether the comparison is valid
public bool CheckKey(BotData data)
{
try
{
return ConditionChecker.Verify(LeftTerm, Condition, RightTerm, data);
}
catch { return false; } // Return false if e.g. we can't parse the number for a LessThan/GreaterThan comparison.
}
}
}