private static PerformanceCounterCategory CreateCategory()
{
if (PerformanceCounterCategory.Exists(PERFORMANCECOUNTER_CATEGORYNAME))
PerformanceCounterCategory.Delete(PERFORMANCECOUNTER_CATEGORYNAME);
//start with the built-in counters
var currentCounters = new List<CounterCreationData>();
currentCounters.AddRange(_defaultCounters);
//add the user-defined custom counters (only the ones that are different from the built-ins)
foreach (var customPerfCounter in RepositoryConfiguration.CustomPerformanceCounters.Cast<CounterCreationData>().
Where(customPerfCounter => !currentCounters.Any(c => c.CounterName == customPerfCounter.CounterName)))
{
currentCounters.Add(customPerfCounter);
}
return PerformanceCounterCategory.Create(PERFORMANCECOUNTER_CATEGORYNAME, "Performance counters of Sense/Net",
PerformanceCounterCategoryType.SingleInstance, new CounterCreationDataCollection(currentCounters.ToArray()));
}
}