Compartilhar via


Método AttributeTableBuilder.AddCustomAttributes (Type, String, array<Attribute )

Adiciona atributos para o membro com o nome especificado.

Namespace:  Microsoft.Windows.Design.Metadata
Assembly:  Microsoft.Windows.Design.Extensibility (em Microsoft.Windows.Design.Extensibility.dll)

Sintaxe

'Declaração
Public Sub AddCustomAttributes ( _
    ownerType As Type, _
    memberName As String, _
    ParamArray attributes As Attribute() _
)
public void AddCustomAttributes(
    Type ownerType,
    string memberName,
    params Attribute[] attributes
)
public:
void AddCustomAttributes(
    Type^ ownerType, 
    String^ memberName, 
    ... array<Attribute^>^ attributes
)
member AddCustomAttributes : 
        ownerType:Type * 
        memberName:string * 
        attributes:Attribute[] -> unit 
public function AddCustomAttributes(
    ownerType : Type, 
    memberName : String, 
    ... attributes : Attribute[]
)

Parâmetros

  • ownerType
    Tipo: System.Type
    O tipo de propriedade do membro.
  • memberName
    Tipo: System.String
    O membro para adicionar atributos.

Exceções

Exceção Condição
ArgumentNullException

ownerType, memberName, or attributes is nulluma referência nula (Nothing no Visual Basic).

Comentários

O membro pode ser uma propriedade ou um evento. O membro é avaliado sob demanda, quando o usuário consulta os atributos de um evento ou a propriedade especificada. Somente os membros de propriedade e evento são suportados. Todos os outros serão ignorados.

Exemplos

O exemplo de código a seguir mostra como adicionar um atributo a um membro. This code example is part of a larger example provided for the AttributeTableBuilder class.

' Apply the ReadOnlyAttribute to the Background property 
' of the Button class.
builder.AddCustomAttributes( _
    GetType(Button), _
    "Background", _
    New ReadOnlyAttribute(True))
// Apply the ReadOnlyAttribute to the Background property 
// of the Button class.
builder.AddCustomAttributes(
    typeof(Button),
    "Background",
    new ReadOnlyAttribute(true));

Segurança do .NET Framework

Consulte também

Referência

AttributeTableBuilder Classe

Sobrecargas AddCustomAttributes

Namespace Microsoft.Windows.Design.Metadata

AttributeTable

AttributeCallbackBuilder