예제 #1
0
            private KernelOutputTranslaterViewModels()
            {
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
#if DEBUG
                NTStopwatch.Start();
#endif
                VirtualRoot.AddEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                                      action: message => {
                    _dicById.Clear();
                    _dicByKernelOutputId.Clear();
                    Init();
                }, location: this.GetType());
                VirtualRoot.AddEventPath <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                                         action: message => {
                    OnPropertyChanged(nameof(AllKernelOutputTranslaterVms));
                }, location: this.GetType());
                AddEventPath <KernelOutputTranslaterAddedEvent>("添加了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                                action: message => {
                    if (KernelOutputVms.TryGetKernelOutputVm(message.Source.KernelOutputId, out KernelOutputViewModel kernelOutputVm))
                    {
                        if (!_dicByKernelOutputId.ContainsKey(message.Source.KernelOutputId))
                        {
                            _dicByKernelOutputId.Add(message.Source.KernelOutputId, new List <KernelOutputTranslaterViewModel>());
                        }
                        var vm = new KernelOutputTranslaterViewModel(message.Source);
                        _dicByKernelOutputId[message.Source.KernelOutputId].Add(vm);
                        _dicById.Add(message.Source.GetId(), vm);
                        kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputTranslaters));
                    }
                }, location: this.GetType());
                AddEventPath <KernelOutputTranslaterUpdatedEvent>("更新了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                                  action: message => {
                    if (_dicByKernelOutputId.TryGetValue(message.Source.KernelOutputId, out List <KernelOutputTranslaterViewModel> vms))
                    {
                        var vm = vms.FirstOrDefault(a => a.Id == message.Source.GetId());
                        if (vm != null)
                        {
                            vm.Update(message.Source);
                        }
                    }
                }, location: this.GetType());
                AddEventPath <KernelOutputTranslaterRemovedEvent>("移除了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                                  action: message => {
                    if (_dicByKernelOutputId.ContainsKey(message.Source.KernelOutputId))
                    {
                        var item = _dicByKernelOutputId[message.Source.KernelOutputId].FirstOrDefault(a => a.Id == message.Source.GetId());
                        if (item != null)
                        {
                            _dicByKernelOutputId[message.Source.KernelOutputId].Remove(item);
                        }
                    }
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById.Remove(message.Source.GetId());
                    }
                    if (KernelOutputVms.TryGetKernelOutputVm(message.Source.KernelOutputId, out KernelOutputViewModel kernelOutputVm))
                    {
                        kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputTranslaters));
                    }
                }, location: this.GetType());
                Init();
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
예제 #2
0
            private KernelOutputKeywordViewModels()
            {
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
#if DEBUG
                NTStopwatch.Start();
#endif
                AddEventPath <KernelOutputKeywordLoadedEvent>("从服务器加载了内核输入关键字后刷新Vm集", LogEnum.DevConsole,
                                                              action: message => {
                    KernelOutputKeywordViewModel[] toRemoves = _dicById.Where(a => a.Value.GetDataLevel() == DataLevel.Global).Select(a => a.Value).ToArray();
                    foreach (var item in toRemoves)
                    {
                        _dicById.Remove(item.Id);
                    }
                    foreach (var kv in _dicByKernelOutputId)
                    {
                        foreach (var toRemove in toRemoves.Where(a => a.KernelOutputId == kv.Key))
                        {
                            kv.Value.Remove(toRemove);
                        }
                    }
                    if (message.Data != null && message.Data.Count != 0)
                    {
                        foreach (var item in message.Data)
                        {
                            var vm = new KernelOutputKeywordViewModel(item);
                            if (!_dicById.ContainsKey(item.Id))
                            {
                                _dicById.Add(item.Id, vm);
                            }
                            if (!_dicByKernelOutputId.ContainsKey(item.KernelOutputId))
                            {
                                _dicByKernelOutputId.Add(item.KernelOutputId, new List <KernelOutputKeywordViewModel>());
                            }
                            _dicByKernelOutputId[item.KernelOutputId].Add(vm);
                        }
                    }
                    if (NTMinerContext.Instance.CurrentMineContext != null)
                    {
                        if (KernelOutputVms.TryGetKernelOutputVm(NTMinerContext.Instance.CurrentMineContext.KernelOutput.GetId(), out KernelOutputViewModel kernelOutputVm))
                        {
                            kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputKeywords));
                        }
                    }
                }, location: this.GetType());
                AddEventPath <UserKernelOutputKeywordAddedEvent>("添加了内核输出过滤器后刷新VM内存", LogEnum.DevConsole,
                                                                 action: message => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        KernelOutputKeywordViewModel vm = new KernelOutputKeywordViewModel(message.Source);
                        _dicById.Add(vm.Id, vm);
                        if (KernelOutputVms.TryGetKernelOutputVm(vm.KernelOutputId, out KernelOutputViewModel kernelOutputVm))
                        {
                            if (!_dicByKernelOutputId.ContainsKey(vm.KernelOutputId))
                            {
                                _dicByKernelOutputId.Add(vm.KernelOutputId, new List <KernelOutputKeywordViewModel>());
                            }
                            _dicByKernelOutputId[vm.KernelOutputId].Add(vm);
                            kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputKeywords));
                        }
                    }
                }, location: this.GetType());
                AddEventPath <UserKernelOutputKeywordUpdatedEvent>("更新了内核输出过滤器后刷新VM内存", LogEnum.DevConsole,
                                                                   action: message => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out KernelOutputKeywordViewModel vm))
                    {
                        vm.Update(message.Source);
                    }
                }, location: this.GetType());
                AddEventPath <UserKernelOutputKeywordRemovedEvent>("删除了内核输出过滤器后刷新VM内存", LogEnum.DevConsole,
                                                                   action: message => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out KernelOutputKeywordViewModel vm))
                    {
                        _dicById.Remove(vm.Id);
                        _dicByKernelOutputId[vm.KernelOutputId].Remove(vm);
                        if (KernelOutputVms.TryGetKernelOutputVm(vm.KernelOutputId, out KernelOutputViewModel kernelOutputVm))
                        {
                            kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputKeywords));
                        }
                    }
                }, location: this.GetType());
                Init();
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
 private KernelOutputTranslaterViewModels()
 {
     if (WpfUtil.IsInDesignMode)
     {
         return;
     }
     VirtualRoot.BuildEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                             path: message => {
         _dicById.Clear();
         _dicByKernelOutputId.Clear();
         Init();
     }, location: this.GetType());
     VirtualRoot.BuildEventPath <ServerContextReInitedEventHandledEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                                         path: message => {
         OnPropertyChanged(nameof(AllKernelOutputTranslaterVms));
     }, location: this.GetType());
     BuildEventPath <KernelOutputTranslaterAddedEvent>("添加了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                       path: message => {
         if (KernelOutputVms.TryGetKernelOutputVm(message.Source.KernelOutputId, out KernelOutputViewModel kernelOutputVm))
         {
             if (!_dicByKernelOutputId.ContainsKey(message.Source.KernelOutputId))
             {
                 _dicByKernelOutputId.Add(message.Source.KernelOutputId, new List <KernelOutputTranslaterViewModel>());
             }
             var vm = new KernelOutputTranslaterViewModel(message.Source);
             _dicByKernelOutputId[message.Source.KernelOutputId].Add(vm);
             _dicById.Add(message.Source.GetId(), vm);
             kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputTranslaters));
         }
     }, location: this.GetType());
     BuildEventPath <KernelOutputTranslaterUpdatedEvent>("更新了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                         path: message => {
         if (_dicByKernelOutputId.TryGetValue(message.Source.KernelOutputId, out List <KernelOutputTranslaterViewModel> vms))
         {
             var vm = vms.FirstOrDefault(a => a.Id == message.Source.GetId());
             if (vm != null)
             {
                 vm.Update(message.Source);
             }
         }
     }, location: this.GetType());
     BuildEventPath <KernelOutputTranslaterRemovedEvent>("移除了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                         path: message => {
         if (_dicByKernelOutputId.ContainsKey(message.Source.KernelOutputId))
         {
             var item = _dicByKernelOutputId[message.Source.KernelOutputId].FirstOrDefault(a => a.Id == message.Source.GetId());
             if (item != null)
             {
                 _dicByKernelOutputId[message.Source.KernelOutputId].Remove(item);
             }
         }
         if (_dicById.ContainsKey(message.Source.GetId()))
         {
             _dicById.Remove(message.Source.GetId());
         }
         if (KernelOutputVms.TryGetKernelOutputVm(message.Source.KernelOutputId, out KernelOutputViewModel kernelOutputVm))
         {
             kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputTranslaters));
         }
     }, location: this.GetType());
     Init();
 }
예제 #4
0
 private KernelOutputKeywordViewModels()
 {
     if (WpfUtil.IsInDesignMode)
     {
         return;
     }
     BuildEventPath <KernelOutputKeywordLoadedEvent>("从服务器加载了内核输入关键字后刷新Vm集", LogEnum.DevConsole, location: this.GetType(), PathPriority.Normal,
                                                     path: message => {
         KernelOutputKeywordViewModel[] toRemoves = _dicById.Where(a => a.Value.GetDataLevel() == DataLevel.Global).Select(a => a.Value).ToArray();
         foreach (var item in toRemoves)
         {
             _dicById.Remove(item.Id);
         }
         foreach (var kv in _dicByKernelOutputId)
         {
             foreach (var toRemove in toRemoves.Where(a => a.KernelOutputId == kv.Key))
             {
                 kv.Value.Remove(toRemove);
             }
         }
         if (message.Data != null && message.Data.Count != 0)
         {
             foreach (var item in message.Data)
             {
                 var vm = new KernelOutputKeywordViewModel(item);
                 if (!_dicById.ContainsKey(item.Id))
                 {
                     _dicById.Add(item.Id, vm);
                 }
                 if (!_dicByKernelOutputId.ContainsKey(item.KernelOutputId))
                 {
                     _dicByKernelOutputId.Add(item.KernelOutputId, new List <KernelOutputKeywordViewModel>());
                 }
                 _dicByKernelOutputId[item.KernelOutputId].Add(vm);
             }
         }
     });
     BuildEventPath <UserKernelOutputKeywordAddedEvent>("添加了内核输出过滤器后刷新VM内存", LogEnum.DevConsole, location: this.GetType(), PathPriority.Normal,
                                                        path: message => {
         if (!_dicById.ContainsKey(message.Source.GetId()))
         {
             KernelOutputKeywordViewModel vm = new KernelOutputKeywordViewModel(message.Source);
             _dicById.Add(vm.Id, vm);
             if (KernelOutputVms.TryGetKernelOutputVm(vm.KernelOutputId, out KernelOutputViewModel kernelOutputVm))
             {
                 if (!_dicByKernelOutputId.ContainsKey(vm.KernelOutputId))
                 {
                     _dicByKernelOutputId.Add(vm.KernelOutputId, new List <KernelOutputKeywordViewModel>());
                 }
                 _dicByKernelOutputId[vm.KernelOutputId].Add(vm);
                 kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputKeywords));
             }
         }
     });
     BuildEventPath <UserKernelOutputKeywordUpdatedEvent>("更新了内核输出过滤器后刷新VM内存", LogEnum.DevConsole, location: this.GetType(), PathPriority.Normal,
                                                          path: message => {
         if (_dicById.TryGetValue(message.Source.GetId(), out KernelOutputKeywordViewModel vm))
         {
             vm.Update(message.Source);
         }
     });
     BuildEventPath <UserKernelOutputKeywordRemovedEvent>("删除了内核输出过滤器后刷新VM内存", LogEnum.DevConsole, location: this.GetType(), PathPriority.Normal,
                                                          path: message => {
         if (_dicById.TryGetValue(message.Source.GetId(), out KernelOutputKeywordViewModel vm))
         {
             _dicById.Remove(vm.Id);
             _dicByKernelOutputId[vm.KernelOutputId].Remove(vm);
             if (KernelOutputVms.TryGetKernelOutputVm(vm.KernelOutputId, out KernelOutputViewModel kernelOutputVm))
             {
                 kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputKeywords));
             }
         }
     });
     Init();
 }