Пример #1
0
        public void MesureTest()
        {
            const string category = "ProfilerTest.MeasureTest";

            Profiler.Enabled         = true;
            Profiler.AutoSaveResults = false;
            const int iteration = 10000;

            using (Profiler.Measure(category, "FullLength"))
            {
                MethodAccessor mi = MethodAccessor.GetAccessor(((Func <int>)TestMethod).Method);
                for (int i = 0; i < iteration; i++)
                {
                    using (Profiler.Measure(category, "InvokeMethod"))
                    {
                        mi.Invoke(this);
                    }
                }
            }

            Assert.AreEqual(2, Profiler.GetMeasurementResults(category).Count());
            var full   = Profiler.GetMeasurementResult(category, "FullLength");
            var invoke = Profiler.GetMeasurementResult(category, "InvokeMethod");

            Assert.AreEqual(1, full.NumberOfCalls);
            Assert.AreEqual(iteration, invoke.NumberOfCalls);
            Assert.IsTrue(full.TotalTime >= invoke.TotalTime);
        }
        private void SetGridViewItems(GridItem[] newItems)
        {
            var items = allGridEntriesAccessor.Get();

            if (items == null)
            {
                return;
            }

            if (newItems == null)
            {
                newItems = new GridItem[0];
            }

            var wasFocused = searchBox.Focused;

            if (gridViewEntriesAccessor == null)
            {
                gridViewEntriesAccessor = new FieldAccessor(items, "entries");
            }

            setScrollOffsetAccessor.Invoke(reflectedGridView, 0);

            gridViewEntriesAccessor.Set(newItems, items);
            gridViewEntriesAccessor.Set(newItems, topLevelGridEntriesAccessor.Get());

            totalPropsAccessor.Set(newItems.Length);
            selectedRowAccessor.Set(0);

            if (newItems.Length > 0)
            {
                selectedGridEntryAccessor.Set(newItems[0]);
            }

            ((Control)reflectedGridView).Invalidate();

            if (wasFocused)
            {
                searchBox.Focus();
            }
        }
Пример #3
0
        private void SetGridViewItems(GridItem[] newItems)
        {
            object items = _allGridEntriesAccessor.Get();

            if (items == null)
            {
                return;
            }

            if (newItems == null)
            {
                newItems = new GridItem[0];
            }

            bool wasFocused = _searchBox.Focused;

            if (_gridViewEntriesAccessor == null)
            {
                _gridViewEntriesAccessor = new FieldAccessor(items, "entries");
            }

            _setScrollOffsetAccessor.Invoke(_reflectedGridView, 0);

            _gridViewEntriesAccessor.Set(newItems, items);
            _gridViewEntriesAccessor.Set(newItems, _topLevelGridEntriesAccessor.Get());

            _totalPropsAccessor.Set(newItems.Length);
            _selectedRowAccessor.Set(0);

            if (newItems.Length > 0)
            {
                _selectedGridEntryAccessor.Set(newItems[0]);
            }

            ((Control)_reflectedGridView).Invalidate();

            if (wasFocused)
            {
                _searchBox.Focus();
            }
        }
Пример #4
0
 public decimal GetBalance(UPlayer player)
 {
     return(_getBalanceMethod.Invoke(player.CSteamId.m_SteamID.ToString()));
 }
Пример #5
0
 public decimal Withdraw(UPlayer player, decimal amount)
 {
     return(_increaseBalanceMethod.Invoke(player.CSteamId.m_SteamID.ToString(), -amount));
 }