コード例 #1
0
        public void Parse()
        {
            var sentence = Sentence.Replace(" ", "");
            var index    = sentence.IndexOf("=");

            Comparer = new ExpressionComparer();
            switch (sentence.Substring(0, index + 1))
            {
            case "=": Comparer.Compare = Comparer.Equal; break;

            case "!=": Comparer.Compare = Comparer.NotEqual; break;

            //case ">": Compare = Greater; break;
            //case ">=": Compare = GreaterOrEqual; break;
            //case "<": Compare = Smaller; break;
            //case "<=": Compare = SmallerOrEqual; break;
            default:
            {
                Comparer = null;
                throw new InvalidExpressionException(string.Format("An expression must start by '=' or '!=' but the expression '{0}' is not.", Sentence));
            }
            }
            Expression = sentence.Substring(index + 1);
            isParsed   = true;
        }
コード例 #2
0
        public void Parse()
        {
            var sentence = Sentence.Replace(" ", "");
            var index = sentence.IndexOf("=");
            Comparer = new ExpressionComparer();
            switch (sentence.Substring(0, index + 1))
            {
                case "=": Comparer.Compare = Comparer.Equal; break;
                case "!=": Comparer.Compare = Comparer.NotEqual; break;
                //case ">": Compare = Greater; break;
                //case ">=": Compare = GreaterOrEqual; break;
                //case "<": Compare = Smaller; break;
                //case "<=": Compare = SmallerOrEqual; break;
                default:
                    {
                        Comparer = null;
                        throw new InvalidExpressionException(string.Format("An expression must start by '=' or '!=' but the expression '{0}' is not.", Sentence));
                    }

            }
            Expression = sentence.Substring(index + 1);
            isParsed = true;
        }