private IEnumerable<MailRule> Parse(ProjectEmailProfile profile, Action<string, object[]> log)
		{
			foreach (var ruleLine in GetRuleLines(profile))
			{
				var parser = new Parser(new Scanner());
				var tree = parser.Parse(ruleLine);
				if (tree.Errors.Count > 0)
				{
					var errors = new StringBuilder();
					tree.Errors.ForEach(x => errors.Append(string.Format("<{0}>", x.Message)));
					log("rule '{0}' can not be parsed because of the following errors: {1}", new object[] {ruleLine, errors});
					continue;
				}

				log("rule '{0}' parsed successfully and prepared to process", new object[] {ruleLine});

				var thenClause = _thenClauseFactory.CreateBy(tree);
				var whenClauses = new WhenClauseFactory(thenClause);
				var whenClause = whenClauses.CreateBy(tree);
				yield return new MailRule(whenClause, thenClause, ruleLine);
			}
		}
Beispiel #2
0
        private IEnumerable <MailRule> Parse(ProjectEmailProfile profile, Action <string, object[]> log)
        {
            foreach (var ruleLine in GetRuleLines(profile))
            {
                var parser = new Parser(new Scanner());
                var tree   = parser.Parse(ruleLine);
                if (tree.Errors.Count > 0)
                {
                    var errors = new StringBuilder();
                    tree.Errors.ForEach(x => errors.Append(string.Format("<{0}>", x.Message)));
                    log("rule '{0}' can not be parsed because of the following errors: {1}", new object[] { ruleLine, errors });
                    continue;
                }

                log("rule '{0}' parsed successfully and prepared to process", new object[] { ruleLine });

                var thenClause  = _thenClauseFactory.CreateBy(tree);
                var whenClauses = new WhenClauseFactory(thenClause);
                var whenClause  = whenClauses.CreateBy(tree);
                yield return(new MailRule(whenClause, thenClause, ruleLine));
            }
        }