using System; namespace PingPong.GameEngine { public class GameCondition { #region Members /// /// The expression. /// private Lazy expression; #endregion #region Properties /// /// Gets the expression. /// /// /// The expression. /// public string Expression { get { return this.expression.Value; } } #endregion #region Constructors /// /// Initializes a new instance of the class. /// public GameCondition() { this.expression = new Lazy(() => string.Empty); } #endregion #region Methods /// /// Evaluate this instance. /// public bool Evaluate() { Engine.ExpressionParser.Interpret(this.Expression); return Engine.ExpressionParser.Output.Equals( bool.TrueString, StringComparison.OrdinalIgnoreCase ); } /// /// Sets the expression. /// /// /// The expression. /// /// /// Expression. /// public GameCondition SetExpression(string expression) { this.expression = new Lazy(() => expression); return this; } #endregion } }