Пример #1
0
        public void TestTrimExcess()
        {
            ActivatableList <ICollectionElement> collection = SingleActivatableCollection();

            collection.Clear();
            collection.TrimExcess();

            Assert.AreEqual(collection.Count, collection.Capacity);
        }
Пример #2
0
        public void TestReadOnly()
        {
            ActivatableList <ICollectionElement>    source   = SingleActivatableCollection();
            ReadOnlyCollection <ICollectionElement> readOnly = source.AsReadOnly();

            IteratorAssert.AreEqual(NewPopulatedPlainList().GetEnumerator(), readOnly.GetEnumerator());

            source.Add(new Element("n"));
            Assert.IsGreaterOrEqual(0, readOnly.IndexOf(new Element("n")));
        }
Пример #3
0
        public void TestSortDefaultComparer()
        {
            ActivatableList <ICollectionElement> actual = SingleActivatableCollection();

            actual.Sort();

            List <ICollectionElement> expected = NewPopulatedPlainList();

            expected.Sort();

            IteratorAssert.AreEqual(expected.GetEnumerator(), actual.GetEnumerator());
        }
Пример #4
0
        public void TestCapacity()
        {
            ActivatableList <ICollectionElement> list = SingleActivatableCollection();

            Assert.IsGreater(0, list.Capacity);
            Assert.IsTrue(Db().IsActive(list));

            Reopen();
            list          = SingleActivatableCollection();
            list.Capacity = 10;
            Assert.IsTrue(Db().IsActive(list));
        }
Пример #5
0
        public void TestBinarySearch1()
        {
            ActivatableList <ICollectionElement> collection = SingleActivatableCollection();

            collection.Sort();
            int count = collection.Count;

            Reopen();

            foreach (string name in Names)
            {
                Assert.IsGreaterOrEqual(0, SingleActivatableCollection().BinarySearch(0, count, new ActivatableElement(name), SimpleComparer.Instance));
            }
        }
Пример #6
0
        public ModLoadingScene(ModdableChessGame game) : base(game)
        {
            connHelper = game.Components.Get <ConnectionHelper>((int)ComponentKeys.ConnectionHelper);
            ActivatableList.Add(new ListenerJanitor <IListener <int> >(
                                    connHelper.Connection.EnterStateMessenger,
                                    new SimpleListener <int>((s) => CheckDisconnect())));

            phase = new StateMachine(0);
            phase.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnStateChange()));
            timer          = 1;
            lobbyChoices   = game.Components.Get <LobbyChoices>((int)ComponentKeys.LobbyChoices);
            startGenerator = Components.GetOrRegister <Query <NetworkGameState> >((int)ComponentKeys.CalculateStartConditions,
                                                                                  Query <NetworkGameState> .Create);

            reqModLoad           = Components.GetOrRegister((int)ComponentKeys.DeepLoadMod, Command <string> .Create);
            sendGameState        = Game.Components.Get <Command <NetworkGameState> >((int)ComponentKeys.LoadingGameStateSend);
            stopRefreshGameState = Game.Components.Get <Command>((int)ComponentKeys.LoadingGameStateStopRefreshing);
            sendReady            = Game.Components.Get <Command <bool> >((int)ComponentKeys.LoadingReadySend);
            sendError            = Game.Components.Get <Command>((int)ComponentKeys.LoadingErrorSend);

            loadingError = Components.GetOrRegister((int)ComponentKeys.ModLoadError, Message <string> .Create);
            loadingError.Subscribe(new SimpleListener <string>(OnModLoadError));

            Components.GetOrRegister((int)ComponentKeys.ModTranslationComplete, Message.Create).Subscribe(new SimpleListener(OnModTranslated));

            ActivatableList.Add(new ListenerJanitor <IListener <NetworkGameState> >(
                                    Game.Components.Get <IMessage <NetworkGameState> >((int)ComponentKeys.LoadingGameStateReceived),
                                    new SimpleListener <NetworkGameState>(OnReceiveConditions)));
            ActivatableList.Add(new ListenerJanitor <IListener>(
                                    Game.Components.Get <IMessage>((int)ComponentKeys.LoadingExitReceived),
                                    new SimpleListener(ReadyToPlay)));
            ActivatableList.Add(new ListenerJanitor <IListener>(
                                    Game.Components.Get <IMessage>((int)ComponentKeys.LoadingErrorReceived),
                                    new SimpleListener(ExitToLobby)));

            new GameStartGenerator(this);
            new BoardCreator(this);
            new ModErrorLog(this);

            CheckDisconnect();
        }
Пример #7
0
 /// <summary>
 /// [Português]
 /// Construtor da classe AvaliaçãoPostural.
 /// <para></para>
 /// [English]
 /// AvaliaçãoPostural class constructor.
 /// </summary>
 public ViewEvaluation()
 {
     Points = new ActivatableList<Point>();
 }
Пример #8
0
        public static void Run()
        {
            String dbname = "index.j.db";

            File.Delete(dbname);

            var ecfg = Db4oEmbedded.NewConfiguration();

            //var memory = new MemoryStorage();
            //ecfg.File.Storage = memory;

            //Db4objects.Db4o.TA.IActivatable act;
            ecfg.Common.Add(new TransparentActivationSupport());
            ecfg.Common.Add(new TransparentPersistenceSupport());
            ecfg.File.GenerateUUIDs = ConfigScope.Globally;

            //ecfg.Common.Diagnostic.AddListener(new DiagnosticToConsole());

            using (var oc = Db4oEmbedded.OpenFile(ecfg, dbname))
            {
                //Test Data
                using (var see = oc.Ext().OpenSession())
                {
                    var list = new ActivatableList <Record>();
                    for (int i = 0; i < 1000; i++)
                    {
                        for (int j = 0; j < 50; j++)
                        {
                            var r = new Record();
                            r.name          = "Name-" + i;
                            r.noName        = r.name;
                            r.indexField    = (double)i;
                            r.noIndexField  = i;
                            r.detail        = new Detail();
                            r.detail.record = r;
                            r.detail.type   = j;
                            r.detail.memo   = r.name + " on meno";
                            list.Add(r);
                        }
                    }
                    see.Store(list);
                    see.Commit();
                }
                using (var see = oc.Ext().OpenSession())
                {
                    Console.WriteLine(see.Query <Record>().Count);
                }

                var ran = new Random();
                for (int i = 0; i < 3; i++)
                {
                    double value = (double)ran.Next(1000);
                    String name  = "Name-" + (int)value;

                    Console.WriteLine("======Value: " + value + " =====");
                    using (var see = oc.Ext().OpenSession())
                    {
                        var st = DateTime.Now;

                        var rs = from Detail d in see where d.type == 10 select d;

                        Console.WriteLine("Size: " + rs.Count());
                        Console.WriteLine("Name: " + rs.ElementAt(0).memo);
                        Console.WriteLine("Name: " + rs.ElementAt(0).record.name);
                        var end = DateTime.Now;
                        Console.WriteLine("Detail Index Time /ms: " + (end - st).TotalMilliseconds + "\r\n");
                    }

                    using (var see = oc.Ext().OpenSession())
                    {
                        var st = DateTime.Now;

                        var rs = from Record r in see where r.name.StartsWith("Name-") select r;

                        Console.WriteLine("Size: " + rs.Count());
                        var end = DateTime.Now;
                        Console.WriteLine("Recrod StartsWith Time /ms: " + (end - st).TotalMilliseconds + "\r\n");
                    }

                    using (var see = oc.Ext().OpenSession())
                    {
                        var st = DateTime.Now;

                        var rs = from Record r in see where r.name.Length > 0 select r;

                        Console.WriteLine("Size: " + rs.Count());
                        var end = DateTime.Now;
                        Console.WriteLine("Recrod Name.Length Time /ms: " + (end - st).TotalMilliseconds + "\r\n");
                    }

                    using (var see = oc.Ext().OpenSession())
                    {
                        var st = DateTime.Now;

                        var rs = from Record r in see where r.name == name select r;

                        Console.WriteLine("Size: " + rs.Count());
                        Console.WriteLine("Name: " + rs.ElementAt(0).name);
                        var end = DateTime.Now;
                        Console.WriteLine("Recrod Index Time /ms: " + (end - st).TotalMilliseconds + "\r\n");
                    }

                    using (var see = oc.Ext().OpenSession())
                    {
                        var st = DateTime.Now;

                        var rs = from Record r in see where r.indexField == value select r;

                        Console.WriteLine("Size: " + rs.Count());
                        var end = DateTime.Now;
                        Console.WriteLine("Recrod Index Time /ms: " + (end - st).TotalMilliseconds + "\r\n");
                    }


                    using (var see = oc.Ext().OpenSession())
                    {
                        var st = DateTime.Now;

                        var rs = from Record r in see where r.indexField == value && r.noName == name select r;

                        Console.WriteLine("Size: " + rs.Count());
                        var end = DateTime.Now;
                        Console.WriteLine("Recrod Index Time /ms: " + (end - st).TotalMilliseconds + "\r\n");
                    }

                    using (var see = oc.Ext().OpenSession())
                    {
                        var st = DateTime.Now;

                        var rs = from Record r in see where r.noIndexField == value select r;

                        Console.WriteLine("Size: " + rs.Count());
                        var end = DateTime.Now;
                        Console.WriteLine("Recrod NoIndex Time /ms: " + (end - st).TotalMilliseconds + "\r\n");
                    }


                    using (var see = oc.Ext().OpenSession())
                    {
                        var st = DateTime.Now;

                        var rs = from Record r in see where r.noName == name select r;

                        Console.WriteLine("Size: " + rs.Count());
                        var end = DateTime.Now;
                        Console.WriteLine("Recrod NoIndex Time /ms: " + (end - st).TotalMilliseconds + "\r\n");
                    }
                }
            }

            Console.WriteLine("End Linq.");
        }
Пример #9
0
 public Series(string seriesName)
 {
     Name = seriesName;
     Episodes = new ActivatableList<Episode>();
 }