ManagementKeyAttribute Classe

Definição

O atributo ManagementKey identifica as propriedades da chave de uma classe WMI.The ManagementKey attribute identifies the key properties of a WMI class.

Observação: as bibliotecas do .NET no WMI agora são consideradas em estado final e nenhum desenvolvimento, melhorias ou atualizações adicionais estarão disponíveis para problemas não relacionados à segurança que afetarem essas bibliotecas.Note: the WMI .NET libraries are now considered in final state, and no further development, enhancements, or updates will be available for non-security related issues affecting these libraries. As APIs de MI devem ser usadas para todos os novos desenvolvimentos.The MI APIs should be used for all new development.

public ref class ManagementKeyAttribute sealed : System::Management::Instrumentation::ManagementMemberAttribute
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false)]
public sealed class ManagementKeyAttribute : System.Management.Instrumentation.ManagementMemberAttribute
[<System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false)>]
type ManagementKeyAttribute = class
    inherit ManagementMemberAttribute
Public NotInheritable Class ManagementKeyAttribute
Inherits ManagementMemberAttribute
Herança
ManagementKeyAttribute
Atributos

Exemplos

O exemplo a seguir mostra como usar o ManagementKeyAttribute para marcar um campo como uma propriedade de chave de uma classe WMI.The following example shows how to use the ManagementKeyAttribute to mark a field as a key property of a WMI class.

[ManagementKey]  
public int id;  

O exemplo a seguir mostra como usar o ManagementKeyAttribute atributo para marcar uma propriedade de chave de uma classe WMI.The next example shows how to use the ManagementKeyAttribute attribute to mark a key property of a WMI class.

// Use the ManagementKey attribute to specify that this property   
// is used as the key identifier of this class and for the WMI  
// instances of this class.  This property must be unique for each  
// class instance.  
[ManagementKey]  
public int Id  
{  
    get { return System.Diagnostics.Process.GetCurrentProcess().Id; }  
}  

Comentários

A menos que uma classe WMI seja um singleton, ela pode ter várias instâncias correspondentes.Unless a WMI class is a singleton, it can have multiple corresponding instances. Os clientes da classe devem ser capazes de identificar exclusivamente a instância específica em que estão interessados.Clients of the class must be able to uniquely identify the specific instance they are interested in. Portanto, como um gravador de provedor, você deve escolher uma propriedade ou um conjunto de propriedades que identifique exclusivamente uma instância de cada uma de suas classes WMI.So, as a provider writer, you must choose a property or set of properties that uniquely identify an instance of each of your WMI classes. Você usa o ManagementKeyAttribute atributo para identificar essas propriedades de chave.You use the ManagementKeyAttribute attribute to identify those key properties. As propriedades identificadas como chaves têm o mesmo comportamento de tempo de execução que as propriedades somente leitura indicadas pelo ManagementProbeAttribute atributo.Properties identified as keys have the same runtime behavior as read-only properties indicated by the ManagementProbeAttribute attribute.

Construtores

ManagementKeyAttribute()

Inicializa uma nova instância da classe ManagementKeyAttribute.Initializes a new instance of the ManagementKeyAttribute class. Esse é o construtor sem parâmetros.This is the parameterless constructor.

Propriedades

Name

Obtém ou define o nome do atributo de gerenciamento.Gets or sets the name of the management attribute.

(Herdado de ManagementMemberAttribute)
TypeId

Quando implementado em uma classe derivada, obtém um identificador exclusivo para este Attribute.When implemented in a derived class, gets a unique identifier for this Attribute.

(Herdado de Attribute)

Métodos

Equals(Object)

Retorna um valor que indica se essa instância é igual a um objeto especificado.Returns a value that indicates whether this instance is equal to a specified object.

(Herdado de Attribute)
GetHashCode()

Retorna o código hash para a instância.Returns the hash code for this instance.

(Herdado de Attribute)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
IsDefaultAttribute()

Quando substituído em uma classe derivada, indica se o valor dessa instância é o valor padrão para a classe derivada.When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Herdado de Attribute)
Match(Object)

Quando substituído em uma classe derivada, retorna um valor que indica se essa instância é igual a um objeto especificado.When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Herdado de Attribute)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)

Implantações explícitas de interface

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Mapeia um conjunto de nomes para um conjunto correspondente de identificadores de expedição.Maps a set of names to a corresponding set of dispatch identifiers.

(Herdado de Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera as informações de tipo para um objeto, que pode ser usado para obter as informações de tipo para uma interface.Retrieves the type information for an object, which can be used to get the type information for an interface.

(Herdado de Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Retorna o número de interfaces de informações do tipo que um objeto fornece (0 ou 1).Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Herdado de Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornece acesso a propriedades e métodos expostos por um objeto.Provides access to properties and methods exposed by an object.

(Herdado de Attribute)

Aplica-se a

Confira também