Add() public method

public Add ( Server aServer ) : bool
aServer Server
return bool
Beispiel #1
0
        public Packets()
        {
            var servers = new Servers();

            var server = new Server
            {
                Name = "test.bitpir.at"
            };
            servers.Add(server);

            var channel = new Channel
            {
                Name = "#test"
            };
            server.AddChannel(channel);

            channel.AddBot(bot1);
            channel.AddBot(bot2);

            bot1.AddPacket(CreatePacket(1, "Under.the.Dome.s01e01.mkv", 101));
            bot1.AddPacket(CreatePacket(2, "Under.the.Dome.s01e02.mkv", 102));
            bot1.AddPacket(CreatePacket(3, "Under.the.Dome.s01e03.mkv", 103));
            bot1.AddPacket(CreatePacket(4, "Under.the.Dome.s01e04.mkv", 104));

            bot2.AddPacket(CreatePacket(1, "Under.the.Dome.s01e01.mkv", 201));
            bot2.AddPacket(CreatePacket(2, "Under.the.Dome.s01e02.mkv", 202));
            bot2.AddPacket(CreatePacket(3, "Under.the.Dome.s01e03.mkv", 203));
            bot2.AddPacket(CreatePacket(4, "Under.the.Dome.s01e04.mkv", 204));
            bot2.AddPacket(CreatePacket(5, "Ander.the.Dome.s01e05.mkv", 205));

            XG.Plugin.Webserver.Search.Packets.Servers = servers;
            XG.Plugin.Webserver.Search.Packets.Initialize();
        }
Beispiel #2
0
        public void CheckAndRemoveDuplicatesTest()
        {
            var servers = new Servers();
            for (int a = 1; a <= count; a++)
            {
                servers.Add(createServer("server " + a));
            }
            servers.Named("server " + count).Name = "server " + fakeId;

            Assert.AreEqual(count, servers.All.Count());
            Assert.AreEqual(count * count, (from server in servers.All from channel in server.Channels select channel).Count());
            Assert.AreEqual(count * count * count, (from server in servers.All from channel in server.Channels from bot in channel.Bots select bot).Count());
            Assert.AreEqual(count * count * count * count, (from server in servers.All from channel in server.Channels from bot in channel.Bots from packet in bot.Packets select packet).Count());

            XG.Business.Helper.Objects.CheckAndRemoveDuplicates(servers);

            int newCount = count - 1;
            Assert.AreEqual(newCount, servers.All.Count());
            Assert.AreEqual(newCount * newCount, (from server in servers.All from channel in server.Channels select channel).Count());
            Assert.AreEqual(newCount * newCount * newCount, (from server in servers.All from channel in server.Channels from bot in channel.Bots select bot).Count());
            Assert.AreEqual(newCount * newCount * newCount * newCount, (from server in servers.All from channel in server.Channels from bot in channel.Bots from packet in bot.Packets select packet).Count());
        }
Beispiel #3
0
        void LoadObjects()
        {
            var _servers = new Servers();
            var _files = new Files();
            var _searches = new Searches();
            var _apiKeys = new ApiKeys();

            using (ISession session = _sessions.OpenSession(new TrackingNumberInterceptor()))
            {
                var servers = session.CreateQuery("FROM Server").List<Server>();
                foreach (var server in servers)
                {
                    _servers.Add(server);
                }

                var files = session.CreateQuery("FROM File").List<File>();
                foreach (var file in files)
                {
                    _files.Add(file);
                }

                var searches = session.CreateQuery("FROM Search").List<Search>();
                foreach (var search in searches)
                {
                    _searches.Add(search);
                }

                var apiKeys = session.CreateQuery("FROM ApiKey").List<ApiKey>();
                foreach (var apiKey in apiKeys)
                {
                    _apiKeys.Add(apiKey);
                }
            }

            Servers = _servers;
            Files = _files;
            Searches = _searches;
            ApiKeys = _apiKeys;

            _lastSave = DateTime.Now;
        }