Ejemplo n.º 1
0
 public Combination(LogicEvaluator evaluator, string statement)
     : base(evaluator)
 {
     this.Items = new List <LogicItem>();
     this.Raw   = statement;
     this.BuildCombination();
 }
Ejemplo n.º 2
0
        public Reference(LogicEvaluator evaluator, string raw)
            : base(evaluator)
        {
            this.Raw   = raw;
            this.Valid = true;
            if (!raw.StartsWith("'"))
            {
                if (StringHelper.IsNumber(raw))
                {
                    this.ReferenceType  = Logic.ReferenceType.Number;
                    this.NumericalValue = decimal.Parse(raw);
                    this.Value          = raw;
                }
                else
                {
                    this.ReferenceType = Logic.ReferenceType.Parameter;
                    this.ParamName     = raw;
                    string val;
                    if (this.Evaluator.TryGetParamValue(raw, out val))
                    {
                        if (StringHelper.IsNumber(val))
                        {
                            NumericalValue = decimal.Parse(val);
                        }
                    }
                    else
                    {
                        switch (this.Evaluator.FailToFindParam)
                        {
                        case FailToFindParamBehaviour.ThrowException:
                            throw new ArgumentException(string.Format("Could not find parameter value in dictionary [{0}]", raw));

                        case FailToFindParamBehaviour.InvalidateClause:
                            this.Valid = false;
                            break;
                        }
                    }

                    Value = val;
                }
            }
            else
            {
                this.ReferenceType = Logic.ReferenceType.Literal;
                var sub = this.Raw.Substring(1);
                this.Value = this.Raw.Substring(1, this.Raw.Substring(1).LastIndexOf("'"));
                if (StringHelper.IsNumber(this.Value))
                {
                    NumericalValue = decimal.Parse(this.Value);
                }
            }
        }
Ejemplo n.º 3
0
 public Statement(LogicEvaluator evaluator, string statement)
     : base(evaluator)
 {
     this.Raw = statement;
     this.BuildStatement();
 }
Ejemplo n.º 4
0
 public LogicItem(LogicEvaluator evaluator)
     : base(evaluator)
 {
 }
Ejemplo n.º 5
0
 public Clause(LogicEvaluator evaluator, string clause)
     : base(evaluator)
 {
     this.Raw = clause;
     this.BuildClause();
 }
Ejemplo n.º 6
0
 public LogicBase(LogicEvaluator evaluator)
 {
     this.Evaluator = evaluator;
 }