public DiscoveryRule(PerformanceCounterCategory pdhCategory) : this() { Name = String.Format("{0} discovery", pdhCategory.CategoryName); Description = String.Format(@"{0} * Note* This discovery rule requires the 'perf_counter.discovery[]' key to be configured on the remote agent to execute the 'Get-CounterSetInstances' Cmdlet. ", pdhCategory.CategoryHelp); Key = String.Format(@"perf_counter.discovery[""{0}""]", pdhCategory.CategoryName); /* * If instances exist on the source machine, search counters on each instance. * Otherwise just call GetCounters() on an empty instance. */ var counters = new Dictionary <String, PerformanceCounter>(); var instances = pdhCategory.GetInstanceNames(); if (instances.Length > 0) { foreach (var instance in instances) { foreach (var pdhCounter in pdhCategory.GetCounters(instance)) { if (pdhCounter.IsValidForExport()) { counters[pdhCounter.CounterName] = pdhCounter; } } } } else { foreach (var pdhCounter in pdhCategory.GetCounters()) { if (pdhCounter.IsValidForExport()) { counters[pdhCounter.CounterName] = pdhCounter; } } } foreach (var pdhCounter in counters.Values) { ItemPrototypes.Add(new Item { Name = String.Format("{0} on {{#INSTANCE}}", pdhCounter.CounterName), Key = String.Format(@"perf_counter[""\{0}({{#INSTANCE}})\{1}""]", pdhCategory.CategoryName, pdhCounter.CounterName), Description = pdhCounter.CounterHelp, }); } }
private void AddItem() { var index = GetNextIndex(); ItemPrototypeModel prototypeModel = new ItemPrototypeModel { Condition = new CraftingCondition(), ItemName = "Item " + index, Value = 0, Index = index }; ItemPrototypes.Add(prototypeModel); SelectedItem = prototypeModel; UpdateSelectedItem(); OnPropertyChanged(nameof(SelectedItem)); OnPropertyChanged(nameof(ItemControl)); OnPropertyChanged(nameof(ItemPrototypes)); }
public void Initialize(Dictionary <ItemPrototypeModel, List <Equipment> > items, double currencySpent) { ItemResults = string.Empty; OnPropertyChanged(nameof(ItemResults)); ItemDictionary = items; ItemPrototypes.Clear(); var itemCount = items.Where(x => x.Key.Value > 0).Sum(x => x.Value.Count); var itemsValue = items.Sum(x => x.Key.Value * x.Value.Count); CurrencyResults = String.Format("You spent {0} chaos crafting {1} items worth a total of {2} chaos", currencySpent, itemCount, itemsValue); foreach (var itemPrototype in ItemDictionary) { ItemPrototypes.Add(itemPrototype.Key); } OnPropertyChanged(nameof(CurrencyResults)); OnPropertyChanged(nameof(ItemPrototypes)); }