Example #1
0
		public WhenThenClause SplitToWhenThenClause(string text)
		{
			if (text.StartsWith("when", StringComparison.InvariantCultureIgnoreCase) == false)
				throw new InvalidOperationException("statement should start with a when");
			int thenIndex = text.IndexOf("then", StringComparison.InvariantCultureIgnoreCase);
			if (thenIndex == -1)
				throw new InvalidOperationException("statement should have a then");
			WhenThenClause clause = new WhenThenClause();
			string whenClause = text.Substring(4, thenIndex - 4).Trim();
			ParseClause(whenClause,
						delegate(string[] parts)
						{
	            			ActionExpression item = new ActionExpression();
	            			item.Left = parts[0];
	            			item.Operator = parts[1];
	            			item.Right = parts[2];
	            			clause.When.Add(item);
						});
			string thenClause = text.Substring(thenIndex + 4);
			ParseClause(thenClause,
						delegate(string[] parts)
						{
	            			ActionExpression item = new ActionExpression();
	            			item.Left = parts[0];
	            			item.Right= parts[1];
	            			item.Operator = parts[2];
	            			clause.Then.Add(item);
						});

			return clause;
		}
Example #2
0
        public WhenThenClause SplitToWhenThenClause(string text)
        {
            if (text.StartsWith("when", StringComparison.InvariantCultureIgnoreCase) == false)
            {
                throw new InvalidOperationException("statement should start with a when");
            }
            int thenIndex = text.IndexOf("then", StringComparison.InvariantCultureIgnoreCase);

            if (thenIndex == -1)
            {
                throw new InvalidOperationException("statement should have a then");
            }
            WhenThenClause clause     = new WhenThenClause();
            string         whenClause = text.Substring(4, thenIndex - 4).Trim();

            ParseClause(whenClause,
                        delegate(string[] parts)
            {
                ActionExpression item = new ActionExpression();
                item.Left             = parts[0];
                item.Operator         = parts[1];
                item.Right            = parts[2];
                clause.When.Add(item);
            });
            string thenClause = text.Substring(thenIndex + 4);

            ParseClause(thenClause,
                        delegate(string[] parts)
            {
                ActionExpression item = new ActionExpression();
                item.Left             = parts[0];
                item.Right            = parts[1];
                item.Operator         = parts[2];
                clause.Then.Add(item);
            });

            return(clause);
        }
		public ExternalDSLDemo(string text)
		{
			parsed = new Parser().Parse(text);
		}
Example #4
0
 public ExternalDSLDemo(string text)
 {
     parsed = new Parser().Parse(text);
 }