コード例 #1
0
        void OnPerfCounterPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            IsDirty = !Equals(ItemServerCounters, ItemResourceCounters);
            if (args.PropertyName == "CounterName")
            {
                var countersByResource = (IPerformanceCountersByResource)sender;

                if (countersByResource.IsNew)
                {
                    {
                        countersByResource.IsNew = false;
                        var newPermission = CreateNewCounter();
                        ResourceCounters.Add(newPermission);
                    }
                }
                else
                {
                    var isEmpty = string.IsNullOrEmpty(countersByResource.CounterName);
                    if (isEmpty)
                    {
                        ResourceCounters.Remove(countersByResource);
                    }
                }
            }
        }
コード例 #2
0
        private void InitializeTos(IPerformanceCounterTo nativeCounters)
        {
            ServerCounters.Clear();
            ResourceCounters.Clear();
            var performanceCountersByMachines = nativeCounters.GetServerCountersTo();

            foreach (var performanceCountersByMachine in performanceCountersByMachines)
            {
                RegisterPropertyChanged(performanceCountersByMachine);
                ServerCounters.Add(performanceCountersByMachine);
            }
            var performanceCountersByResources = nativeCounters.GetResourceCountersTo();

            foreach (var performanceCountersByResource in performanceCountersByResources)
            {
                RegisterPropertyChanged(performanceCountersByResource);
                ResourceCounters.Add(performanceCountersByResource);
            }
            ResourceCounters.Add(CreateNewCounter());
            SetItem(nativeCounters);
        }