InstanceDataCollection 클래스

정의

InstanceData 개체의 강력한 형식의 컬렉션을 제공합니다.

public ref class InstanceDataCollection : System::Collections::DictionaryBase
public class InstanceDataCollection : System.Collections.DictionaryBase
type InstanceDataCollection = class
    inherit DictionaryBase
Public Class InstanceDataCollection
Inherits DictionaryBase
상속
InstanceDataCollection

예제

다음 코드 예제에서는 로컬 컴퓨터에서 특정 PerformanceCounterCategory 에 대 한 인스턴스 데이터를 표시 합니다. 먼저 번호가 매겨진 이름 목록을 PerformanceCounterCategory 표시합니다. 사용자가 범주 중 하나의 번호를 입력한 후 예제에서는 해당 PerformanceCounterCategory에 대한 를 InstanceDataCollectionCollection 가져옵니다. 그런 다음 에서 반환 Values 된 컬렉션을 개체 배열 InstanceDataCollection 로 변환합니다. 이 예제에서는 각 InstanceDataInstanceDataCollection와 연결된 인스턴스 데이터도 표시합니다.

using System;
using System.Diagnostics;
using System.Collections;

class InstDataKeysValuesMod
{

    private static string categoryName;

    public static void Main()
    {
        string catNumStr;
        int categoryNum;

        PerformanceCounterCategory[] categories = PerformanceCounterCategory.GetCategories();

        Console.WriteLine("These categories are registered on this computer:");

        int catX;
        for(catX=0; catX<categories.Length; catX++)
        {
            Console.WriteLine("{0,4} - {1}", catX+1, categories[catX].CategoryName);
        }

        // Ask the user to choose a category.
        Console.Write("Enter the category number from the above list: ");
        catNumStr = Console.ReadLine();

        // Validate the entered category number.
        try
        {
            categoryNum = int.Parse(catNumStr);
            if (categoryNum<1||categoryNum>categories.Length)
            {
                throw new Exception(String.Format("The category number must be in the " +
                    "range 1..{0}.", categories.Length));
            }
            categoryName = categories[(categoryNum - 1)].CategoryName;
        }
        catch(Exception ex)
        {
            Console.WriteLine("\"{0}\" is not a valid category number." +
                "\r\n{1}", catNumStr, ex.Message);
            return;
        }

        // Process the InstanceDataCollectionCollection for this category.
        PerformanceCounterCategory pcc = new PerformanceCounterCategory(categoryName);
        InstanceDataCollectionCollection idColCol = pcc.ReadCategory();

        ICollection idColColKeys = idColCol.Keys;
        string[] idCCKeysArray = new string[idColColKeys.Count];
        idColColKeys.CopyTo(idCCKeysArray, 0);

        ICollection idColColValues = idColCol.Values;
        InstanceDataCollection[] idCCValuesArray = new InstanceDataCollection[idColColValues.Count];
        idColColValues.CopyTo(idCCValuesArray, 0);

        Console.WriteLine("InstanceDataCollectionCollection for \"{0}\" " +
            "has {1} elements.", categoryName, idColCol.Count);

        // Display the InstanceDataCollectionCollection Keys and Values.
        // The Keys and Values collections have the same number of elements.
        int index;
        for(index=0; index<idCCKeysArray.Length; index++)
        {
            Console.WriteLine("  Next InstanceDataCollectionCollection " +
                "Key is \"{0}\"", idCCKeysArray[index]);
            ProcessInstanceDataCollection(idCCValuesArray[index]);
        }
    }

    // Display the contents of an InstanceDataCollection.
    public static void ProcessInstanceDataCollection(InstanceDataCollection idCol)
    {

        ICollection idColKeys = idCol.Keys;
        string[] idColKeysArray = new string[idColKeys.Count];
        idColKeys.CopyTo(idColKeysArray, 0);

        ICollection idColValues = idCol.Values;
        InstanceData[] idColValuesArray = new InstanceData[idColValues.Count];
        idColValues.CopyTo(idColValuesArray, 0);

        Console.WriteLine("  InstanceDataCollection for \"{0}\" " +
            "has {1} elements.", idCol.CounterName, idCol.Count);

        // Display the InstanceDataCollection Keys and Values.
        // The Keys and Values collections have the same number of elements.
        int index;
        for(index=0; index<idColKeysArray.Length; index++)
        {
            Console.WriteLine("    Next InstanceDataCollection " +
                "Key is \"{0}\"", idColKeysArray[index]);
            ProcessInstanceDataObject(idColValuesArray[index]);
        }
    }

    // Display the contents of an InstanceData object.
    public static void ProcessInstanceDataObject(InstanceData instData)
    {
        CounterSample sample = instData.Sample;

        Console.WriteLine("    From InstanceData:\r\n      " +
            "InstanceName: {0,-31} RawValue: {1}", instData.InstanceName, instData.Sample.RawValue);
        Console.WriteLine("    From CounterSample:\r\n      " +
            "CounterType: {0,-32} SystemFrequency: {1}\r\n" +
            "      BaseValue: {2,-34} RawValue: {3}\r\n" +
            "      CounterFrequency: {4,-27} CounterTimeStamp: {5}\r\n" +
            "      TimeStamp: {6,-34} TimeStamp100nSec: {7}", sample.CounterType, sample.SystemFrequency, sample.BaseValue, sample.RawValue, sample.CounterFrequency, sample.CounterTimeStamp, sample.TimeStamp, sample.TimeStamp100nSec);
    }
}
Imports System.Diagnostics
Imports System.Collections

Module InstDataKeysValuesMod

    Private categoryName As String

    Sub Main()
        Dim catNumStr As String
        Dim categoryNum As Integer

        Dim categories As PerformanceCounterCategory() = _
            PerformanceCounterCategory.GetCategories()

        Console.WriteLine( _
            "These categories are registered on this computer:")

        Dim catX As Integer
        For catX = 0 To categories.Length - 1
            Console.WriteLine("{0,4} - {1}", catX + 1, _
                categories(catX).CategoryName)
        Next catX

        ' Ask the user to choose a category.
        Console.Write( _
            "Enter the category number from the above list: ")
        catNumStr = Console.ReadLine()

        ' Validate the entered category number.
        Try
            categoryNum = Integer.Parse(catNumStr)
            If categoryNum < 1 Or categoryNum > categories.Length Then
                Throw New Exception( _
                    String.Format("The category number must be in the " & _
                        "range 1..{0}.", categories.Length))
            End If
            categoryName = categories((categoryNum - 1)).CategoryName

        Catch ex As Exception
            Console.WriteLine("""{0}"" is not a valid category number." & _
                vbCrLf & "{1}", catNumStr, ex.Message)
            Return
        End Try

        ' Process the InstanceDataCollectionCollection for this category.
        Dim pcc As New PerformanceCounterCategory(categoryName)
        Dim idColCol As InstanceDataCollectionCollection = pcc.ReadCategory()

        Dim idColColKeys As ICollection = idColCol.Keys
        Dim idCCKeysArray(idColColKeys.Count - 1) As String
        idColColKeys.CopyTo(idCCKeysArray, 0)

        Dim idColColValues As ICollection = idColCol.Values
        Dim idCCValuesArray(idColColValues.Count - 1) As InstanceDataCollection
        idColColValues.CopyTo(idCCValuesArray, 0)

        Console.WriteLine("InstanceDataCollectionCollection for ""{0}"" " & _
            "has {1} elements.", categoryName, idColCol.Count)

        ' Display the InstanceDataCollectionCollection Keys and Values.
        ' The Keys and Values collections have the same number of elements.
        Dim index As Integer
        For index = 0 To idCCKeysArray.Length - 1
            Console.WriteLine("  Next InstanceDataCollectionCollection " & _
                "Key is ""{0}""", idCCKeysArray(index))
            ProcessInstanceDataCollection(idCCValuesArray(index))
        Next index
    End Sub

    ' Display the contents of an InstanceDataCollection.
    Sub ProcessInstanceDataCollection(ByVal idCol As InstanceDataCollection)

        Dim idColKeys As ICollection = idCol.Keys
        Dim idColKeysArray(idColKeys.Count - 1) As String
        idColKeys.CopyTo(idColKeysArray, 0)

        Dim idColValues As ICollection = idCol.Values
        Dim idColValuesArray(idColValues.Count - 1) As InstanceData
        idColValues.CopyTo(idColValuesArray, 0)

        Console.WriteLine("  InstanceDataCollection for ""{0}"" " & _
            "has {1} elements.", idCol.CounterName, idCol.Count)

        ' Display the InstanceDataCollection Keys and Values.
        ' The Keys and Values collections have the same number of elements.
        Dim index As Integer
        For index = 0 To idColKeysArray.Length - 1
            Console.WriteLine("    Next InstanceDataCollection " & _
                "Key is ""{0}""", idColKeysArray(index))
            ProcessInstanceDataObject(idColValuesArray(index))
        Next index
    End Sub

    ' Display the contents of an InstanceData object.
    Sub ProcessInstanceDataObject(ByVal instData As InstanceData)
        Dim sample As CounterSample = instData.Sample

        Console.WriteLine("    From InstanceData:" & vbCrLf & "      " & _
            "InstanceName: {0,-31} RawValue: {1}", _
            instData.InstanceName, instData.Sample.RawValue)
        Console.WriteLine("    From CounterSample:" & vbCrLf & "      " & _
            "CounterType: {0,-32} SystemFrequency: {1}" & vbCrLf & _
            "      BaseValue: {2,-34} RawValue: {3}" & vbCrLf & _
            "      CounterFrequency: {4,-27} CounterTimeStamp: {5}" & vbCrLf & _
            "      TimeStamp: {6,-34} TimeStamp100nSec: {7}", _
            sample.CounterType, sample.SystemFrequency, sample.BaseValue, _
            sample.RawValue, sample.CounterFrequency, sample.CounterTimeStamp, _
            sample.TimeStamp, sample.TimeStamp100nSec)
    End Sub
End Module

설명

클래스는 InstanceDataCollection 카운터에 대한 모든 인스턴스 데이터를 포함하는 컬렉션을 나타냅니다. 이 컬렉션에 포함 되는 InstanceDataCollectionCollection 경우 ReadCategory 는 메서드.

생성자

InstanceDataCollection(String)
사용되지 않음.
사용되지 않음.
사용되지 않음.

성능 인스턴스를 정의하는 지정된 성능 카운터를 사용하여 InstanceDataCollection 클래스의 새 인스턴스를 초기화합니다.

속성

Count

DictionaryBase 인스턴스에 포함된 요소 수를 가져옵니다.

(다음에서 상속됨 DictionaryBase)
CounterName

해당 인스턴스 데이터가 들어 있는 성능 카운터의 이름을 가져옵니다.

Dictionary

DictionaryBase 인스턴스에 포함된 요소의 목록을 가져옵니다.

(다음에서 상속됨 DictionaryBase)
InnerHashtable

DictionaryBase 인스턴스에 포함된 요소의 목록을 가져옵니다.

(다음에서 상속됨 DictionaryBase)
Item[String]

이 카운터와 관련된 인스턴스 데이터를 가져옵니다. 이 데이터는 일반적으로 원시 카운터 값의 집합입니다.

Keys

이 인스턴스 데이터와 관련된 개체 및 개체의 카운터 레지스트리 키를 가져옵니다.

Values

카운터의 인스턴스 데이터를 구성하는 원시 카운터 값을 가져옵니다.

메서드

Clear()

DictionaryBase 인스턴스의 콘텐츠를 지웁니다.

(다음에서 상속됨 DictionaryBase)
Contains(String)

인덱싱된 InstanceData 개체 중 하나로 식별되는 지정된 이름의 성능 인스턴스가 해당 컬렉션에 존재하는지 여부를 확인합니다.

CopyTo(Array, Int32)

지정한 인덱스에서 1차원 DictionaryBaseArray 엔트리를 복사합니다.

(다음에서 상속됨 DictionaryBase)
CopyTo(InstanceData[], Int32)

컬렉션의 항목을 지정된 1차원 배열의 지정된 인덱스에 복사합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetEnumerator()

IDictionaryEnumerator 인스턴스를 반복하는 DictionaryBase를 반환합니다.

(다음에서 상속됨 DictionaryBase)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
OnClear()

DictionaryBase 인스턴스의 내용을 지우기 전에 추가로 사용자 지정 프로세스를 수행합니다.

(다음에서 상속됨 DictionaryBase)
OnClearComplete()

DictionaryBase 인스턴스의 내용을 지운 후에 추가로 사용자 지정 프로세스를 수행합니다.

(다음에서 상속됨 DictionaryBase)
OnGet(Object, Object)

DictionaryBase 인스턴스에서 지정한 키와 값이 있는 요소를 가져옵니다.

(다음에서 상속됨 DictionaryBase)
OnInsert(Object, Object)

DictionaryBase 인스턴스에 새 요소를 삽입하기 전에 추가로 사용자 지정 프로세스를 수행합니다.

(다음에서 상속됨 DictionaryBase)
OnInsertComplete(Object, Object)

DictionaryBase 인스턴스에 새 요소를 삽입한 후에 추가로 사용자 지정 프로세스를 수행합니다.

(다음에서 상속됨 DictionaryBase)
OnRemove(Object, Object)

DictionaryBase 인스턴스에서 요소를 제거하기 전에 추가로 사용자 지정 프로세스를 수행합니다.

(다음에서 상속됨 DictionaryBase)
OnRemoveComplete(Object, Object)

DictionaryBase 인스턴스에서 요소를 제거한 후에 추가로 사용자 지정 프로세스를 수행합니다.

(다음에서 상속됨 DictionaryBase)
OnSet(Object, Object, Object)

DictionaryBase 인스턴스에 값을 설정하기 전에 추가로 사용자 지정 프로세스를 수행합니다.

(다음에서 상속됨 DictionaryBase)
OnSetComplete(Object, Object, Object)

DictionaryBase 인스턴스에 값을 설정한 후에 추가로 사용자 지정 프로세스를 수행합니다.

(다음에서 상속됨 DictionaryBase)
OnValidate(Object, Object)

지정한 키와 값을 가지는 요소의 유효성을 검사할 때 추가로 사용자 지정 프로세스를 수행합니다.

(다음에서 상속됨 DictionaryBase)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

ICollection.IsSynchronized

DictionaryBase 개체에 대한 액세스가 동기화되어 스레드로부터 안전하게 보호되는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 DictionaryBase)
ICollection.SyncRoot

DictionaryBase 개체에 대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다.

(다음에서 상속됨 DictionaryBase)
IDictionary.Add(Object, Object)

지정한 키와 값을 가지는 요소를 DictionaryBase에 추가합니다.

(다음에서 상속됨 DictionaryBase)
IDictionary.Contains(Object)

DictionaryBase에 특정 키가 들어 있는지 여부를 확인합니다.

(다음에서 상속됨 DictionaryBase)
IDictionary.IsFixedSize

DictionaryBase 개체의 크기가 고정되어 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 DictionaryBase)
IDictionary.IsReadOnly

DictionaryBase 개체가 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 DictionaryBase)
IDictionary.Item[Object]

지정된 키에 연결된 값을 가져오거나 설정합니다.

(다음에서 상속됨 DictionaryBase)
IDictionary.Keys

ICollection 개체의 키가 포함된 DictionaryBase 개체를 가져옵니다.

(다음에서 상속됨 DictionaryBase)
IDictionary.Remove(Object)

DictionaryBase에서 지정한 키를 가지는 요소를 제거합니다.

(다음에서 상속됨 DictionaryBase)
IDictionary.Values

ICollection 개체의 값이 포함된 DictionaryBase 개체를 가져옵니다.

(다음에서 상속됨 DictionaryBase)
IEnumerable.GetEnumerator()

IEnumerator를 반복하는 DictionaryBase를 반환합니다.

(다음에서 상속됨 DictionaryBase)

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보