Esempio n. 1
0
        public static IEnumerable <Expression> Iterate(ISet <Expression> visitedExpressions, Expression expressionToIterate)
        {
            BinaryUnion binaryUnion = expressionToIterate.As <BinaryUnion>();

            if (binaryUnion != null)
            {
                foreach (Expression expression in Iterate(visitedExpressions, binaryUnion.Left.AsSequence().Concat(binaryUnion.Right)))
                {
                    if (visitedExpressions.Add(expression))
                    {
                        yield return(expression);
                    }
                }

                yield break;
            }

            Union union = expressionToIterate.As <Union>();

            if (union != null)
            {
                foreach (Expression expression in Iterate(visitedExpressions, union.Expressions))
                {
                    if (visitedExpressions.Add(expression))
                    {
                        yield return(expression);
                    }
                }

                yield break;
            }

            yield return(expressionToIterate);
        }
Esempio n. 2
0
        public override Expression ToRegExp()
        {
            Entity     prev       = null;
            Expression expression = null;

            foreach (Entity entity in EntityCollection)
            {
                if (prev == null)
                {
                    expression = entity.ToRegExp();
                }
                else
                {
                    expression = new RegExpBinaryUnion(expression, entity.ToRegExp());
                }

                prev = entity;
            }

            return(expression);
        }