Пример #1
0
        public void HeartbeatReceived(Heartbeat heartbeat)
        {
            Action w = () =>
                {
                    if (!_hearbeatIndex.ContainsKey(heartbeat.Key))
                    {
                        Heartbeats.Add(new SelectableDataItem(heartbeat.Message));
                        _hearbeatIndex.TryAdd(heartbeat.Key, heartbeat);
                    }
                    else
                    {
                        var item = Heartbeats.Where(s => s.Value.ToString().Contains(heartbeat.Key)).FirstOrDefault();
                        item.Value = heartbeat.Message;
                        _hearbeatIndex.AddOrUpdate(heartbeat.Key, heartbeat, (n, oldValue) => heartbeat);

                        // resuscitate
                        if (heartbeat.Key == StaleModule) HeartbeatLost = Visibility.Collapsed;
                    }
                };
            DispatcherFacade.AddToDispatcherQueue(w);
        }
Пример #2
0
 private void Heartbeat(long l)
 {
     var heartbeat = new Heartbeat(_dynamicViewName, String.Format("{0} View heartbeat sent at: {1}", _dynamicViewName, DateTime.UtcNow.ToLongTimeString()), DateTime.UtcNow, false);
     Action w = () => Mediator.GetInstance.Broadcast(Topic.ShellStateUpdated, heartbeat);
     AddToDispatcherQueue(w);
 }
Пример #3
0
        private void InjectServices()
        {
            foreach (var lazy in Services)
            {
                var service = lazy.Value;
                Mediator.GetInstance.Register(service);
                var heartbeat = new Heartbeat(service.GetType().ToString(), String.Format("{0} Service loaded at: {1}", service.GetType(), DateTime.UtcNow.ToLongTimeString()), DateTime.UtcNow, true);

                Mediator.GetInstance.Broadcast(Topic.ShellStateUpdated, heartbeat);
            }
            //inject service observers
            foreach (var lazy in ServiceObservers)
            {
                lazy.Value.AddServicesToObserve(Services.Select(s => s.Value));
            }
        }
Пример #4
0
        private static void UnloadView(string key)
        {
            Window view;
            if (RunningWindows.TryGetValue(key, out view))
            {
                Action close = () => view.Close();
                view.Dispatcher.BeginInvoke(close);
                Window removed;
                RunningWindows.TryRemove(key, out removed);
                view.Dispatcher.BeginInvoke((Action)(() => Mediator.GetInstance.Unregister(removed.DataContext)));
                var heartbeat = new Heartbeat(removed.GetType().ToString(), String.Format("{0} View unloaded at: {1}", removed.GetType(), DateTime.UtcNow.ToLongTimeString()), DateTime.UtcNow, true);

                Mediator.GetInstance.Broadcast(Topic.ShellStateUpdated, heartbeat);
            }
        }
Пример #5
0
        private static void CreateView(Lazy<IDynamicViewModel> lazy)
        {
            var vm = lazy.Value;

            Mediator.GetInstance.Register(vm);
            Window view = (Window)((BaseViewModel)vm).ViewReference;
            RunningWindows.TryAdd(vm.DynamicViewName, view);
            var heartbeat = new Heartbeat(vm.GetType().ToString(), String.Format("{0} View loaded at: {1}", vm.GetType().ToString(), DateTime.UtcNow.ToLongTimeString()), DateTime.UtcNow, true);

            Mediator.GetInstance.Broadcast(Topic.ShellStateUpdated, heartbeat);
        }