public static PerformanceCounterCategory[] GetCategories(string machineName) { if (!SyntaxCheck.CheckMachineName(machineName)) { throw new ArgumentException(SR.GetString("InvalidParameter", new object[] { "machineName", machineName })); } new PerformanceCounterPermission(PerformanceCounterPermissionAccess.Browse, machineName, "*").Demand(); string[] categories = PerformanceCounterLib.GetCategories(machineName); PerformanceCounterCategory[] categoryArray = new PerformanceCounterCategory[categories.Length]; for (int i = 0; i < categoryArray.Length; i++) { categoryArray[i] = new PerformanceCounterCategory(categories[i], machineName); } return(categoryArray); }
/// <summary> /// Returns an array of performance counter categories for a particular machine. /// </summary> public static PerformanceCounterCategory[] GetCategories(string machineName) { if (!SyntaxCheck.CheckMachineName(machineName)) { throw new ArgumentException(SR.Format(SR.InvalidParameter, nameof(machineName), machineName), nameof(machineName)); } string[] categoryNames = PerformanceCounterLib.GetCategories(machineName); PerformanceCounterCategory[] categories = new PerformanceCounterCategory[categoryNames.Length]; for (int index = 0; index < categories.Length; index++) { categories[index] = new PerformanceCounterCategory(categoryNames[index], machineName); } return(categories); }
/// <devdoc> /// Returns an array of performance counter categories for a particular machine. /// </devdoc> public static PerformanceCounterCategory[] GetCategories(string machineName) { if (!SyntaxCheck.CheckMachineName(machineName)) { throw new ArgumentException(SR.GetString(SR.InvalidParameter, "machineName", machineName)); } PerformanceCounterPermission permission = new PerformanceCounterPermission(PerformanceCounterPermissionAccess.Read, machineName, "*"); permission.Demand(); string[] categoryNames = PerformanceCounterLib.GetCategories(machineName); PerformanceCounterCategory[] categories = new PerformanceCounterCategory[categoryNames.Length]; for (int index = 0; index < categories.Length; index++) { categories[index] = new PerformanceCounterCategory(categoryNames[index], machineName); } return(categories); }