public virtual Task <QueryResult <T> > QueryAsync <TResult>(Expression <Func <T, bool> > @where, Expression <Func <T, TResult> > @select, bool distinct, int skip, int take, CancellationToken cancellationToken) { if (@where == null) { @where = i => true; } var predicate = where.Compile(); var totalValues = _collection.Where(predicate.Invoke); if (distinct) { totalValues = totalValues.Distinct(); } var resultValues = totalValues .Skip(skip) .Take(take) .ToArray(); int totalCount = 0; if (FetchQueryResultTotal) { totalCount = totalValues.Count(); } var result = new QueryResult <T>(new AsyncEnumerableWrapper <T>(resultValues), totalCount); return(Task.FromResult(result)); }
public bool Execute(params object[] Params) { Habbo Player = (Habbo)Params[0]; if (Player == null) { return(false); } int.TryParse(StringData, out int scoreToGet); RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username); if (Instance.GetGameManager().Points[(int)User.Team] < scoreToGet) { return(false); } Player.WiredInteraction = true; System.Collections.Generic.ICollection <IWiredItem> Effects = Instance.GetWired().GetEffects(this); System.Collections.Generic.ICollection <IWiredItem> Conditions = Instance.GetWired().GetConditions(this); foreach (IWiredItem Condition in Conditions.ToList()) { if (!Condition.Execute(Player)) { return(false); } Instance.GetWired().OnEvent(Condition.Item); } bool HasRandomEffectAddon = Effects.Where(x => x.Type == WiredBoxType.AddonRandomEffect).ToList().Any(); if (HasRandomEffectAddon) { //Okay, so we have a random addon effect, now lets get the IWiredItem and attempt to execute it. IWiredItem RandomBox = Effects.FirstOrDefault(x => x.Type == WiredBoxType.AddonRandomEffect); if (!RandomBox.Execute()) { return(false); } //Success! Let's get our selected box and continue. IWiredItem SelectedBox = Instance.GetWired().GetRandomEffect(Effects.ToList()); if (!SelectedBox.Execute()) { return(false); } //Woo! Almost there captain, now lets broadcast the update to the room instance. Instance?.GetWired().OnEvent(RandomBox.Item); Instance?.GetWired().OnEvent(SelectedBox.Item); } else { foreach (IWiredItem Effect in Effects.ToList()) { if (!Effect.Execute(Player)) { return(false); } Instance.GetWired().OnEvent(Effect.Item); } } return(true); }