Exemplo n.º 1
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            var baseConfig = EventStoreConfig.GetConfig();

            var promotionsConfig = new DummyEventStoreConfig(DbManager.FixedConnectionstring, baseConfig);
            var user1Config      = new DummyEventStoreConfig(DbManager.FixedConnectionstring, baseConfig);
            var user2Config      = new DummyEventStoreConfig(DbManager.FixedConnectionstring, baseConfig);

            StatsMonitor = new StatsMonitor();

            EventSystem.Create(
                MicroserviceFactory <UserManagement, UserManagementHandler>
                .CreateEventProcessor("user1", user1Config, null, plugin, persistIncomingEvents, false,
                                      SetupInMemoryPersistence <UserManagement>),

                MicroserviceFactory <UserManagement, UserManagementHandler>
                .CreateEventProcessor("user2", user2Config, null, plugin, persistIncomingEvents, false,
                                      SetupInMemoryPersistence <UserManagement>),

                MicroserviceFactory <Promotions, PromotionsHandler> .
                CreateEventProcessor("promo", promotionsConfig, null, plugin, persistIncomingEvents, false,
                                     SetupInMemoryPersistence <Promotions>,
                                     (consumer, serializer, payload) =>
            {
                var e = serializer.Deserialize <IEvent>(payload);
                if (e is FreePointsRewardedToUser)
                {
                    return(false);
                }
                return(true);
            }));
        }
        public void TestTriggerByTransaction()
        {
            Configuration.StatsUpdateTransactionCount = 10;
            Configuration.StatsUpdateTimespan         = 0;
            bool triggered    = false;
            var  statsMonitor = new StatsMonitor();

            statsMonitor.Initialize(new StoreStatistics(10UL, DateTime.UtcNow, 0UL, new Dictionary <string, ulong>()),
                                    18UL, () => { triggered = true; });
            statsMonitor.OnJobScheduled();
            Assert.IsFalse(triggered);
            statsMonitor.OnJobScheduled();
            Assert.IsTrue(triggered);
            triggered = false;
            statsMonitor.OnJobScheduled();
            Assert.IsFalse(triggered, "Monitor should not retrigger on txn immediately after firing.");
        }
        public void TestTriggerByTimespan()
        {
            Configuration.StatsUpdateTimespan         = 60;
            Configuration.StatsUpdateTransactionCount = 0;
            bool triggered    = false;
            var  statsMonitor = new StatsMonitor();

            statsMonitor.Initialize(new StoreStatistics(10UL, DateTime.UtcNow.Subtract(TimeSpan.FromSeconds(59)), 0UL, new Dictionary <string, ulong>()),
                                    12UL, () => { triggered = true; });
            statsMonitor.OnJobScheduled();
            Assert.IsFalse(triggered);
            Thread.Sleep(TimeSpan.FromSeconds(2.0));
            statsMonitor.OnJobScheduled();
            Assert.IsTrue(triggered);
            triggered = false;
            statsMonitor.OnJobScheduled();
            Assert.IsFalse(triggered, "Monitor should not retrigger on time immediately after firing.");
        }
        public void TestTriggerByBoth()
        {
            Configuration.StatsUpdateTimespan         = 60;
            Configuration.StatsUpdateTransactionCount = 6;
            bool triggered    = false;
            var  statsMonitor = new StatsMonitor();

            statsMonitor.Initialize(new StoreStatistics(10UL, DateTime.UtcNow.Subtract(TimeSpan.FromSeconds(59)), 0UL, new Dictionary <string, ulong>()),
                                    12UL, () => { triggered = true; });
            statsMonitor.OnJobScheduled(); // 13
            Assert.IsFalse(triggered);
            Thread.Sleep(TimeSpan.FromSeconds(2.0));
            statsMonitor.OnJobScheduled(); // 14
            Assert.IsFalse(triggered);
            statsMonitor.OnJobScheduled(); // 15
            Assert.IsFalse(triggered);
            statsMonitor.OnJobScheduled(); // 16 - should trigger udpate
            Assert.IsTrue(triggered);
            triggered = false;
            // Subsequent job should not re-trigger
            statsMonitor.OnJobScheduled();
            Assert.IsFalse(triggered);
        }
Exemplo n.º 5
0
        // ----------------------------------------------------------------------------
        // Protected & Private Methods
        // ----------------------------------------------------------------------------

        private void CreateUI()
        {
            /* Create UI canvas used for all StatsMonitorWrapper components. */
            _canvas                  = gameObject.AddComponent <Canvas>();
            _canvas.renderMode       = RenderMode.ScreenSpaceCamera;
            _canvas.pixelPerfect     = true;
            _canvas.sortingLayerName = StatsMonitor.NAME + "SortingLayer";
            _canvas.worldCamera      = GameObject.Find("UICamera").GetComponent <Camera>();

            RectTransform tr = gameObject.GetComponent <RectTransform>();

            tr.pivot            = Vector2.up;
            tr.anchorMin        = Vector2.up;
            tr.anchorMax        = Vector2.up;
            tr.anchoredPosition = new Vector2(0.0f, 0.0f);

            /* Find the widget game object to enable it on start. */
            GameObject widget = transform.Find(StatsMonitor.NAME).gameObject;

            widget.SetActive(true);

            /* Find StatsMonitor child object. */
            _statsMonitor = FindObjectOfType <StatsMonitor>();
        }
Exemplo n.º 6
0
        // ----------------------------------------------------------------------------
        // Constructor
        // ----------------------------------------------------------------------------

        internal StatsView(StatsMonitor statsMonitor)
        {
            _statsMonitor = statsMonitor;
            Invalidate();
        }
Exemplo n.º 7
0
        // ----------------------------------------------------------------------------
        // Constructor
        // ----------------------------------------------------------------------------

        internal CustomInfoView(StatsMonitor statsMonitor)
        {
            _statsMonitor = statsMonitor;
            Invalidate();
        }
Exemplo n.º 8
0
        // ----------------------------------------------------------------------------
        // Constructor
        // ----------------------------------------------------------------------------

        public GraphView(StatsMonitor statsMonitor)
        {
            _statsMonitor = statsMonitor;
            Invalidate();
        }
Exemplo n.º 9
0
        // ----------------------------------------------------------------------------
        // Unity Editor Callbacks
        // ----------------------------------------------------------------------------

        public void OnEnable()
        {
            _self = (target as StatsMonitor);

            /* General parameters section */
            _mode                 = serializedObject.FindProperty("_mode");
            _style                = serializedObject.FindProperty("_style");
            _alignment            = serializedObject.FindProperty("_alignment");
            _keepAlive            = serializedObject.FindProperty("_keepAlive");
            _statsUpdateInterval  = serializedObject.FindProperty("_statsUpdateInterval");
            _graphUpdateInterval  = serializedObject.FindProperty("_graphUpdateInterval");
            _objectsCountInterval = serializedObject.FindProperty("_objectsCountInterval");

            /* Hot keys section */
            _inputEnabled      = serializedObject.FindProperty("inputEnabled");
            _hotKeyGroupToggle = serializedObject.FindProperty("hotKeyGroupToggle");
            _modKeyToggle      = serializedObject.FindProperty("modKeyToggle");
            _hotKeyToggle      = serializedObject.FindProperty("hotKeyToggle");
            _modKeyAlignment   = serializedObject.FindProperty("modKeyAlignment");
            _hotKeyAlignment   = serializedObject.FindProperty("hotKeyAlignment");
            _modKeyStyle       = serializedObject.FindProperty("modKeyStyle");
            _hotKeyStyle       = serializedObject.FindProperty("hotKeyStyle");

            /* Hot keys section */
            _touchControlGroupToggle = serializedObject.FindProperty("touchControlGroupToggle");
            _toggleTouchCount        = serializedObject.FindProperty("toggleTouchCount");
            _switchAlignmentTapCount = serializedObject.FindProperty("switchAlignmentTapCount");
            _switchStyleTapCount     = serializedObject.FindProperty("switchStyleTapCount");

            /* Look and feel section */
            _layoutAndStylingToggle = serializedObject.FindProperty("layoutAndStylingToggle");
            _fontFace         = serializedObject.FindProperty("fontFace");
            _fontSizeLarge    = serializedObject.FindProperty("fontSizeLarge");
            _fontSizeSmall    = serializedObject.FindProperty("fontSizeSmall");
            _padding          = serializedObject.FindProperty("padding");
            _spacing          = serializedObject.FindProperty("spacing");
            _graphHeight      = serializedObject.FindProperty("graphHeight");
            _autoScale        = serializedObject.FindProperty("autoScale");
            _scale            = serializedObject.FindProperty("scale");
            _colorBGUpper     = serializedObject.FindProperty("colorBGUpper");
            _colorBGLower     = serializedObject.FindProperty("colorBGLower");
            _colorGraphBG     = serializedObject.FindProperty("colorGraphBG");
            _colorFPS         = serializedObject.FindProperty("colorFPS");
            _colorFPSWarning  = serializedObject.FindProperty("colorFPSWarning");
            _colorFPSCritical = serializedObject.FindProperty("colorFPSCritical");
            _colorFPSMin      = serializedObject.FindProperty("colorFPSMin");
            _colorFPSMax      = serializedObject.FindProperty("colorFPSMax");
            _colorFPSAvg      = serializedObject.FindProperty("colorFPSAvg");
            _colorFXD         = serializedObject.FindProperty("colorFXD");
            _colorMS          = serializedObject.FindProperty("colorMS");
            _colorGCBlip      = serializedObject.FindProperty("colorGCBlip");
            _colorObjCount    = serializedObject.FindProperty("colorObjCount");
            _colorMemTotal    = serializedObject.FindProperty("colorMemTotal");
            _colorMemAlloc    = serializedObject.FindProperty("colorMemAlloc");
            _colorMemMono     = serializedObject.FindProperty("colorMemMono");
            _colorSysInfoOdd  = serializedObject.FindProperty("colorSysInfoOdd");
            _colorSysInfoEven = serializedObject.FindProperty("colorSysInfoEven");
            _colorOutline     = serializedObject.FindProperty("colorOutline");

            /* FPS-Specific section */
            _fpsGroupToggle     = serializedObject.FindProperty("fpsGroupToggle");
            _warningThreshold   = serializedObject.FindProperty("_warningThreshold");
            _criticalThreshold  = serializedObject.FindProperty("_criticalThreshold");
            _throttleFrameRate  = serializedObject.FindProperty("_throttleFrameRate");
            _throttledFrameRate = serializedObject.FindProperty("_throttledFrameRate");
            _avgSamples         = serializedObject.FindProperty("_avgSamples");
        }