Esempio n. 1
0
        public void IndexedCollection_Remove()
        {
            int count      = 10;
            var collection = new IndexedCollection <int, TestObject>(t => t.Sequence);

            collection.AddRange(_objects.GetRange(0, count));

            Assert.AreEqual(true, collection.Remove(_objects[9]));
            Assert.AreEqual(false, collection.Remove(_objects[9]));
            Assert.AreEqual(count - 1, collection.Count);
        }
            public async Task ShopRemove(int index)
            {
                index -= 1;
                if (index < 0)
                {
                    return;
                }

                var gc = uow.GuildConfigs.For(Context.Guild.Id, set => set.Include(x => x.ShopEntries).ThenInclude(x => x.Items));

                var entries       = new IndexedCollection <ShopEntry>(gc.ShopEntries);
                var entryToRemove = entries.ElementAtOrDefault(index);

                if (entryToRemove != null)
                {
                    entries.Remove(entryToRemove);

                    gc.ShopEntries = entries;
                    await uow.SaveChangesAsync(false).ConfigureAwait(false);

                    await Context.Channel.EmbedAsync(EntryToEmbed(entryToRemove).WithTitle(GetText("shop_item_rm")));
                }
                else
                {
                    await ReplyErrorLocalized("shop_item_not_found").ConfigureAwait(false);
                }
            }
Esempio n. 3
0
 public void RemoveTest()
 {
     Collection.Add("Name");
     Assert.AreEqual(Collection.Length, 1);
     Collection.Remove("Name");
     Assert.AreEqual(Collection.Length, 0);
 }
Esempio n. 4
0
    internal bool Remove(int ServerID = -1)
    {
        if (ServerID == -1)
        {
            Connections.Clear();
            zServers.Clear();
            zStacks.Clear();

            return(true);
        }

        Connections.RemoveServer(ServerID);
        zServers.Remove(ServerID);
        zStacks.Remove(ServerID);

        return(true);
    }
Esempio n. 5
0
            public async Task ShopRemove(int index)
            {
                index -= 1;
                if (index < 0)
                {
                    return;
                }
                ShopEntry removed;

                using (var uow = _db.UnitOfWork)
                {
                    var config = uow.GuildConfigs.For(Context.Guild.Id, set => set
                                                      .Include(x => x.ShopEntries)
                                                      .ThenInclude(x => x.Items));

                    var entries = new IndexedCollection <ShopEntry>(config.ShopEntries);
                    removed = entries.ElementAtOrDefault(index);
                    if (removed != null)
                    {
                        entries.Remove(removed);

                        config.ShopEntries = entries;
                        uow.Complete();
                    }
                }

                if (removed == null)
                {
                    await ReplyErrorLocalized("shop_item_not_found").ConfigureAwait(false);
                }
                else
                {
                    await Context.Channel.EmbedAsync(EntryToEmbed(removed)
                                                     .WithTitle(GetText("shop_item_rm")));
                }
            }
Esempio n. 6
0
 private void RemoveSaga(TSaga saga)
 {
     lock (_collection)
         _collection.Remove(saga);
 }