예제 #1
0
        public void Eager_Validation_Source_ValueTaskPredicate()
        {
            var target = new ThrowingAsyncEnumerable <bool>();

            Assert.Throws <ArgumentNullException>(() =>
            {
                var noIterate = AsyncEnumerable.Any((IAsyncEnumerable <bool>)null, QuickFunctions <bool> .IdentityWrapped);
            });
        }
예제 #2
0
        public void Eager_Validation_Predicate_ValueTaskPredicate()
        {
            var target = new ThrowingAsyncEnumerable <bool>();

            Assert.Throws <ArgumentNullException>(() =>
            {
                var noIterate = AsyncEnumerable.Any(target, (Func <bool, ValueTask <bool> >)null);
            });
        }
예제 #3
0
        public void Eager_Validation_Source_NoPredicate()
        {
            var target = new ThrowingAsyncEnumerable <bool>();

            Assert.Throws <ArgumentNullException>(() =>
            {
                var noIterate = AsyncEnumerable.Any((IAsyncEnumerable <bool>)null);
            });
        }
예제 #4
0
        public async Task <bool> ApplyFriendAsync(EaUser user, string fid)
        {
            var fuser = await _userManager.FindByIdAsync(fid);

            if (fuser == null)
            {
                return(false);//失败
            }
            var has = await AsyncEnumerable.Any(f => f.IsEnable && f.Target == user.Id || f.Creator == user.Id);

            if (fuser.Id == user.Id || has)
            {
                return(false);
            }
            DbSet.Add(new Friend()
            {
                Creator = user.Id,
                Target  = fid
            });
            var res = await DbContext.SaveChangesAsync();

            return(res > 0);
        }
 public static Task <bool> AnyAsync <TSource>(this IAsyncEnumerable <TSource> source, Func <TSource, bool> predicate, CancellationToken cancellationToken = default)
 => AsyncEnumerable.Any(source, predicate, cancellationToken);