Files
PowerShell/src/Microsoft.PowerShell.Commands.Diagnostics/CounterSet.cs
T
PowerShell Team 403ae3f53f Initial run of code formatter
I (Jason Shirk) ran https://github.com/dotnet/codeformatter with the default rules, basically:

    codeformatter /nocopyright "/c:DEBUG,UNIX,CORECLR" @files.rsp

This caused a few problems building, which were fixed up manually.

Notable changes:

`this.` is removed unless needed to disambiguate.
private instance fields are renamed to have a `_` prefix.
private static fields are renamed to have a `s_` prefix.

I left some projects alone (like PackageManagement) and also left some generated code alone.
2016-08-01 15:57:03 -07:00

133 lines
3.9 KiB
C#

//
// Copyright (c) 2008 Microsoft Corporation. All rights reserved.
//
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Diagnostics;
using System.ComponentModel;
namespace Microsoft.PowerShell.Commands.GetCounter
{
public class CounterSet
{
internal CounterSet(string setName,
string machineName,
PerformanceCounterCategoryType categoryType,
string setHelp,
ref Dictionary<string, string[]> counterInstanceMapping)
{
_counterSetName = setName;
if (machineName == null || machineName.Length == 0)
{
machineName = ".";
}
else
{
_machineName = machineName;
if (!_machineName.StartsWith(@"\\", StringComparison.OrdinalIgnoreCase))
{
_machineName = @"\\" + _machineName;
}
}
_counterSetType = categoryType;
_description = setHelp;
_counterInstanceMapping = counterInstanceMapping;
}
public string CounterSetName
{
get
{
return _counterSetName;
}
}
private string _counterSetName = "";
public string MachineName
{
get
{
return _machineName;
}
}
private string _machineName = ".";
public PerformanceCounterCategoryType CounterSetType
{
get
{
return _counterSetType;
}
}
private PerformanceCounterCategoryType _counterSetType;
public string Description
{
get
{
return _description;
}
}
private string _description = "";
internal Dictionary<string, string[]> CounterInstanceMapping
{
get
{
return _counterInstanceMapping;
}
}
private Dictionary<string, string[]> _counterInstanceMapping;
public StringCollection Paths
{
get
{
StringCollection retColl = new StringCollection();
foreach (string counterName in this.CounterInstanceMapping.Keys)
{
string path;
if (CounterInstanceMapping[counterName].Length != 0)
{
path = (_machineName == ".") ?
("\\" + _counterSetName + "(*)\\" + counterName) :
(_machineName + "\\" + _counterSetName + "(*)\\" + counterName);
}
else
{
path = (_machineName == ".") ?
("\\" + _counterSetName + "\\" + counterName) :
(_machineName + "\\" + _counterSetName + "\\" + counterName);
}
retColl.Add(path);
}
return retColl;
}
}
public StringCollection PathsWithInstances
{
get
{
StringCollection retColl = new StringCollection();
foreach (string counterName in CounterInstanceMapping.Keys)
{
foreach (string instanceName in CounterInstanceMapping[counterName])
{
string path = (_machineName == ".") ?
("\\" + _counterSetName + "(" + instanceName + ")\\" + counterName) :
(_machineName + "\\" + _counterSetName + "(" + instanceName + ")\\" + counterName);
retColl.Add(path);
}
}
return retColl;
}
}
}
}