Exemplo n.º 1
0
        private void WordsControl_Load(object sender, EventArgs e)
        {
            var wordsStorage = WordStorage.getInstance();

            loadWords(wordsStorage.getWords());
            wordsStorage.wordsUpdated += (words) => {
                runOnGui(() => {
                    loadWords(words);
                });
            };

            wordsStorage.wordUpdated += (word) => {
                runOnGui(() => {
                    EditWordRowControl item = wordControls.Find(control => control.Id == word.Id);
                    if (item != null)
                    {
                        item.Names = word.Names;
                        item.Code  = word.Code;
                    }
                    else
                    {
                        var newItem = createWordControl(word);
                        FLPlist.ScrollControlIntoView(newItem);
                    }
                });
            };

            wordsStorage.wordDeleted += removeWord;
        }
Exemplo n.º 2
0
        private static void Main()
        {
            // One-time initialization per application
            DotsRuntime.Initialize();

            // Setup the global static string interning storage
            TempMemoryScope.EnterScope();
            WordStorage.Initialize();
            TempMemoryScope.ExitScope();

            // A UnityInstance can exist per game state (there may potentially be more than one)
            var unity = UnityInstance.Initialize();

            unity.OnTick = (double timestampInSeconds) =>
            {
                var shouldContinue = unity.Update(timestampInSeconds);
                if (shouldContinue == false)
                {
                    unity.Deinitialize();
                }
                return(shouldContinue);
            };

            // Anything which can come after EnterMainLoop must occur in an event because
            // on some platforms EnterMainLoop exits immediately and the application enters
            // an event-driven lifecycle.
            PlatformEvents.OnQuit          += (object sender, QuitEvent evt) => { Shutdown(); };
            PlatformEvents.OnSuspendResume += (object sender, SuspendResumeEvent evt) => { unity.Suspended = evt.Suspend; };

            // Run
            RunLoop.EnterMainLoop(unity.OnTick);

            // DON'T CALL ANY CLEANUP HERE!
        }
Exemplo n.º 3
0
        public void GetWords_ShouldReturnEmptyListOnLetter()
        {
            var provider = this.CreateProviderMock();
            var storage  = new WordStorage(provider);
            var stored   = storage.GetWords('b');

            stored.Should().BeEmpty();
        }
Exemplo n.º 4
0
        private static void Shutdown()
        {
            // Cleanup of word storage
            TempMemoryScope.EnterScope();
            WordStorage.Shutdown();
            TempMemoryScope.ExitScope();

            DotsRuntime.Shutdown();
        }
Exemplo n.º 5
0
 void createWordCache()
 {
     searchOptimizedWords = WordStorage.getInstance().getWords().Select((word) => new SearchOptimizedWord()
     {
         Word  = word,
         Names = word.Names.Split().Select(name => name.Trim()).ToArray()
     }).ToList();
     search();
 }
        public virtual void Setup()
        {
            backupCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = testCulture;
//disable obsolete word/numberedwords collections
#pragma warning disable 0618
            WordStorage.Setup();
#pragma warning restore 0618
        }
Exemplo n.º 7
0
 private void BaddWord_Click(object sender, EventArgs e)
 {
     WordStorage.getInstance().AddWord(new Word()
     {
         Id    = WordStorage.getInstance().getNextId(),
         Code  = "3F",
         Names = "",
     });
 }
Exemplo n.º 8
0
        public void GetWords_ShouldReturnEmptyListEmptyWords()
        {
            var words    = new HashSet <string>();
            var provider = this.CreateProviderMock(('b', words));
            var storage  = new WordStorage(provider);
            var stored   = storage.GetWords('b');

            stored.Should().BeEmpty();
        }
Exemplo n.º 9
0
        private void TBname_TextChanged(object sender, EventArgs e)
        {
            var word = WordStorage.getInstance().getWordById(Id);

            if (word.Names != TBname.Text)
            {
                word.Names = TBname.Text;
                WordStorage.getInstance().UpdateWord(word);
            }
        }
Exemplo n.º 10
0
        public void InstantiateKeepsName()
        {
            WordStorage.Setup();
            var entity = m_Manager.CreateEntity();

            m_Manager.SetName(entity, "Blah");

            var instance = m_Manager.Instantiate(entity);

            Assert.AreEqual("Blah", m_Manager.GetName(instance));
        }
Exemplo n.º 11
0
        public void GetWords_ShouldSearchByLower()
        {
            var words = new HashSet <string> {
                "beacon", "borsch"
            };
            var provider = this.CreateProviderMock(('b', words));
            var storage  = new WordStorage(provider);
            var stored   = storage.GetWords('B');

            stored.Should().HaveCount(words.Count);
        }
Exemplo n.º 12
0
        private void TBcode_TextChanged(object sender, EventArgs e)
        {
            updateLetter();
            var word = WordStorage.getInstance().getWordById(Id);

            if (word.Code != TBcode.Text)
            {
                word.Code = TBcode.Text;
                WordStorage.getInstance().UpdateWord(word);
            }
        }
Exemplo n.º 13
0
        public SearchControl()
        {
            InitializeComponent();
            createWordCache();
            var wordStorage = WordStorage.getInstance();

            wordStorage.wordDeleted += (_) => {
                createWordCache();
            };
            wordStorage.wordsUpdated += (_) => {
                createWordCache();
            };
            wordStorage.wordUpdated += (_) => {
                createWordCache();
            };
            setupList();
        }
Exemplo n.º 14
0
 private void Pdelete_Click(object sender, EventArgs e)
 {
     if (SettingsStorage.getInstance().getSettings().ConfirmDelete)
     {
         var confirmResult = MessageBox.Show("Are you sure to delete this item ??",
                                             "Confirm Delete!!",
                                             MessageBoxButtons.YesNo);
         ParentForm.Show();
         if (confirmResult == DialogResult.Yes)
         {
             WordStorage.getInstance().removeWord(Id);
         }
     }
     else
     {
         WordStorage.getInstance().removeWord(Id);
     }
 }
Exemplo n.º 15
0
        public void NameEntities()
        {
            WordStorage.Setup();
            var archetype = m_Manager.CreateArchetype(typeof(EcsTestData));
            var count     = 1024;
            var array     = new NativeArray <Entity>(count, Allocator.Temp);

            m_Manager.CreateEntity(archetype, array);
            for (int i = 0; i < count; i++)
            {
                m_Manager.SetName(array[i], "Name" + i);
            }
            for (int i = 0; i < count; ++i)
            {
                Assert.AreEqual(m_Manager.GetName(array[i]), "Name" + i);
            }
            // even though we've made 1024 entities, the string table should contain only two entries:
            // "", and "Name"
            Assert.IsTrue(WordStorage.Instance.Entries == 2);
            array.Dispose();
        }
Exemplo n.º 16
0
    public static int Main(string[] args)
    {
        // Not using UnityInstance.Initialize here because it also creates a world, and some tests exist
        // that expect to handle their own world life cycle which currently conflicts with our world design
        UnityInstance.BurstInit();

        DotsRuntime.Initialize();

        TempMemoryScope.EnterScope();
        // Static storage used for the whole lifetime of the process. Create it once here
        // so heap tracking tests won't fight over the storage causing alloc/free mismatches
        WordStorage.Initialize();

        // TypeManager initialization uses temp memory, so let's free it before creating a global scope
        Unity.Entities.TypeManager.Initialize();
        TempMemoryScope.ExitScope();

        // Should have stack trace with tests
        NativeLeakDetection.Mode = NativeLeakDetectionMode.EnabledWithStackTrace;

        int result = 0;

#if UNITY_PORTABLE_TEST_RUNNER
        double start = Time.timeAsDouble;
        UnitTestRunner.Run();
        double end = Time.timeAsDouble;
        PrintResults(end - start);
#else
        result = new AutoRun().Execute(args);
#endif

        TempMemoryScope.EnterScope();
        Unity.Entities.TypeManager.Shutdown();
        WordStorage.Shutdown();
        TempMemoryScope.ExitScope();

        DotsRuntime.Shutdown();

        return(result);
    }
Exemplo n.º 17
0
 public WordStorageDebugView(WordStorage wordStorage)
 {
     m_wordStorage = wordStorage;
 }
Exemplo n.º 18
0
 public virtual void Setup()
 {
     backupCulture = Thread.CurrentThread.CurrentCulture;
     Thread.CurrentThread.CurrentCulture = testCulture;
     WordStorage.Setup();
 }
Exemplo n.º 19
0
 public virtual void Setup()
 {
     WordStorage.Setup();
 }