コード例 #1
0
ファイル: Extensions.drop.cs プロジェクト: lin5/Theraot
        public static bool TryTakeUntil <T>(this IDropPoint <T> dropPoint, Predicate <T> check, ICollection <T> trail)
        {
            if (check == null)
            {
                throw new ArgumentNullException("check");
            }
            if (dropPoint == null)
            {
                throw new ArgumentNullException("dropPoint");
            }
            if (trail == null)
            {
                throw new ArgumentNullException("trail");
            }
            T item;

back:
            if (dropPoint.TryTake(out item))
            {
                if (check(item))
                {
                    return(true);
                }
                trail.Add(item);
                goto back;
            }
            return(false);
        }
コード例 #2
0
ファイル: Extensions.drop.cs プロジェクト: rjmcguire/Theraot
        public static bool TryTakeUntil <T>(this IDropPoint <T> dropPoint, Predicate <T> check, out T item)
        {
            if (check == null)
            {
                throw new ArgumentNullException("check");
            }
            if (dropPoint == null)
            {
                throw new ArgumentNullException("dropPoint");
            }
back:
            if (dropPoint.TryTake(out item))
            {
                if (check(item))
                {
                    return(true);
                }
                else
                {
                    goto back;
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
ファイル: Extensions.drop.cs プロジェクト: lin5/Theraot
        public static bool TryTakeAndIgnore <T>(this IDropPoint <T> dropPoint)
        {
            if (dropPoint == null)
            {
                throw new ArgumentNullException("dropPoint");
            }
            T item;

            return(dropPoint.TryTake(out item));
        }
コード例 #4
0
ファイル: Extensions.drop.cs プロジェクト: lin5/Theraot
        public static T TakeAndReturn <T>(this IDropPoint <T> dropPoint)
        {
            if (dropPoint == null)
            {
                throw new ArgumentNullException("dropPoint");
            }
            T item;

            if (dropPoint.TryTake(out item))
            {
                return(item);
            }
            throw new InvalidOperationException();
        }