File size: 3,193 Bytes
8c763fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Resources;

namespace Microsoft.PowerShell.Commands.GetCounter
{
    public class PerformanceCounterSample
    {
        internal PerformanceCounterSample()
        {
        }

        internal PerformanceCounterSample(string path,
                               string instanceName,
                               double cookedValue,
                               UInt64 rawValue,
                               UInt64 secondValue,
                               uint multiCount,
                               PerformanceCounterType counterType,
                               UInt32 defaultScale,
                               UInt64 timeBase,
                               DateTime timeStamp,
                               UInt64 timeStamp100nSec,
                               UInt32 status)
        {
            Path = path;
            InstanceName = instanceName;
            CookedValue = cookedValue;
            RawValue = rawValue;
            SecondValue = secondValue;
            MultipleCount = multiCount;
            CounterType = counterType;
            DefaultScale = defaultScale;
            TimeBase = timeBase;
            Timestamp = timeStamp;
            Timestamp100NSec = timeStamp100nSec;
            Status = status;
        }

        public string Path { get; set; } = string.Empty;

        public string InstanceName { get; set; } = string.Empty;

        public double CookedValue { get; set; }

        public UInt64 RawValue { get; set; }

        public UInt64 SecondValue { get; set; }

        public uint MultipleCount { get; set; }

        public PerformanceCounterType CounterType { get; set; }

        public DateTime Timestamp { get; set; } = DateTime.MinValue;

        public UInt64 Timestamp100NSec { get; set; }

        public UInt32 Status { get; set; }

        public UInt32 DefaultScale { get; set; }

        public UInt64 TimeBase { get; set; }
    }

    public class PerformanceCounterSampleSet
    {
        internal PerformanceCounterSampleSet()
        {
            _resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager();
        }

        internal PerformanceCounterSampleSet(DateTime timeStamp,
                                    PerformanceCounterSample[] counterSamples,
                                    bool firstSet) : this()
        {
            Timestamp = timeStamp;
            CounterSamples = counterSamples;
        }

        public DateTime Timestamp { get; set; } = DateTime.MinValue;

        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays",
                    Scope = "member",
                    Target = "Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSample.CounterSamples",
                    Justification = "A string[] is required here because that is the type Powershell supports")]
        public PerformanceCounterSample[] CounterSamples { get; set; }

        private readonly ResourceManager _resourceMgr = null;
    }
}