Sarcasm.Unparsing.FormatYielder.YieldAfterComments C# (CSharp) Méthode

YieldAfterComments() private méthode

private YieldAfterComments ( UnparsableAst owner, Comments comments, UnparseCommentDelegate unparseComment ) : IEnumerable
owner UnparsableAst
comments Comments
unparseComment UnparseCommentDelegate
Résultat IEnumerable
        internal IEnumerable<UtokenBase> YieldAfterComments(UnparsableAst owner, Comments comments, UnparseCommentDelegate unparseComment)
        {
            IList<Comment> afterComments;
            IList<Comment> afterCommentsForFormatter;
            Func<IEnumerable<Comment>, int, IEnumerable<Comment>> skipOrTake;

            if (direction == Unparser.Direction.LeftToRight)
            {
                afterComments = comments.Right;
                afterCommentsForFormatter = comments.Right;
                skipOrTake = Enumerable.Take;
            }
            else
            {
                afterComments = comments.Left.ReverseOptimized();
                afterCommentsForFormatter = comments.Left;
                skipOrTake = Enumerable.Skip;
            }

            foreach (var afterComment in afterComments.Select((beforeComment, commentIndex) => new { Value = beforeComment, Index = commentIndex }))
            {
                int index;
                int commentCountToSkipOrTake;

                if (direction == Unparser.Direction.LeftToRight)
                {
                    index = afterComment.Index;
                    commentCountToSkipOrTake = index;
                }
                else
                {
                    index = afterComments.Count - 1 - afterComment.Index;
                    commentCountToSkipOrTake = index + 1;
                }

                yield return formatter.GetUtokensBetweenCommentAndOwner(owner, afterComment.Value, index, afterComments.Count, skipOrTake(afterCommentsForFormatter, commentCountToSkipOrTake))
                    .SetKind(InsertedUtokens.Kind.Between)
                    .SetAffected(owner);

                foreach (UtokenBase utoken in unparseComment(owner, afterComment.Value))
                    yield return utoken;
            }
        }