Example #1
0
        public static IEnumerable AsEnumerable(this Query query, bool revertAll = false)
        {
            try
            {
                Trail.Enter();

                var nextQuery = query;

                while (nextQuery != null)
                {
                    var currentQuery = nextQuery;
                    var result       = currentQuery.Run();

                    switch (result.Type)
                    {
                    case QueryResultType.ChoicePoint:
                        nextQuery = result.Continuation;
                        Trail.Current.ChoicePoint(result.Alternate);
                        break;

                    case QueryResultType.Success:
                        yield return(null);

                        nextQuery = Trail.Current.Backtrack();
                        break;

                    default:
                        nextQuery = Trail.Current.Backtrack();
                        break;
                    }
                }
            }
            finally
            {
                Trail.Exit(revertAll);
            }
        }