forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounterSet.cs
More file actions
132 lines (121 loc) · 3.95 KB
/
Copy pathCounterSet.cs
File metadata and controls
132 lines (121 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//
// 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;
}
}
}
}