Sdílet prostřednictvím


AttributeTable – třída

Tabulka atributy metadat pro definování návrhu vzhledu a chování.

Hierarchie dědičnosti

System.Object
  Microsoft.Windows.Design.Metadata.AttributeTable

Obor názvů:  Microsoft.Windows.Design.Metadata
Sestavení:  Microsoft.Windows.Design.Extensibility (v Microsoft.Windows.Design.Extensibility.dll)

Syntaxe

'Deklarace
Public NotInheritable Class AttributeTable
public sealed class AttributeTable
public ref class AttributeTable sealed
[<Sealed>]
type AttributeTable =  class end
public final class AttributeTable

Typ AttributeTable zveřejňuje následující členy.

Vlastnosti

  Název Popis
Veřejná vlastnost AttributedTypes Získá všechny typy, které mají atribut přepis určitého druhu, například na vlastnost nebo samotný datový typ výčtu.

Na začátek

Metody

  Název Popis
Veřejná metoda ContainsAttributes Vrátí hodnotu označující, zda tato tabulka obsahuje metadata pro zadaný typ.
Veřejná metoda Equals Určuje, zda zadaná Object se rovná aktuální Object. (Zděděno z Object.)
Chráněná metoda Finalize Umožňuje zkuste uvolnit prostředky a provádět další operace vyčištění před je převzaty systémem pro uvolnění objektu. (Zděděno z Object.)
Veřejná metoda GetCustomAttributes(Assembly) Vrátí hodnotu výčtu všech atributů podle zadané sestavení.
Veřejná metoda GetCustomAttributes(Type) Vrátí hodnotu výčtu všech atributů podle zadaného typu.
Veřejná metoda GetCustomAttributes(Type, String) Vrátí hodnotu výčtu všech atributů pro zadaný typ a název členu.
Veřejná metoda GetHashCode Slouží jako funkce hash určitého typu. (Zděděno z Object.)
Veřejná metoda GetType Získává Type aktuální instance. (Zděděno z Object.)
Chráněná metoda MemberwiseClone Vytvoří kopii aktuální Object. (Zděděno z Object.)
Veřejná metoda ToString Vrátí řetězec, který představuje aktuální objekt. (Zděděno z Object.)

Na začátek

Poznámky

Použití AttributeTable třídy přidružení atributy metadat návrhu s typy Windows Presentation Foundation (WPF).

Chcete-li vytvořit tabulku atributů volání CreateTable metodu AttributeTableBuilder Třída Další informace naleznete v tématu Poskytování metadata prvků Design.

Tabulka atributů je v podstatě slovník jen pro čtení, ale jeho klíče a hodnoty vypočítané samostatně. Je účinný pokud obsahuje atributy pro určitý typ dotazu tabulku atributů. Skutečná sada atributů je vytvořena poptávka.

Příklady

Následující příklad kódu ukazuje, jak vytvořit a naplnit tabulku atributů. Další informace naleznete v tématu Walkthrough: Creating a Design-time Adorner.

Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Reflection
Imports System.Text
Imports System.Windows.Media
Imports System.Windows.Controls
Imports System.Windows

Imports Microsoft.Windows.Design
Imports Microsoft.Windows.Design.Features
Imports Microsoft.Windows.Design.Metadata

' The ProvideMetadata assembly-level attribute indicates to designers
' that this assembly contains a class that provides an attribute table. 
<Assembly: ProvideMetadata(GetType(CustomControlLibrary.VisualStudio.Design.Metadata))> 

' Container for any general design-time metadata to initialize.
' Designers look for a type in the design-time assembly that 
' implements IProvideAttributeTable. If found, designers instantiate
' this class and access its AttributeTable property automatically.
Friend Class Metadata
    Implements IProvideAttributeTable

    ' Accessed by the designer to register any design-time metadata.
    Public ReadOnly Property AttributeTable() As AttributeTable _
        Implements IProvideAttributeTable.AttributeTable
        Get
            Dim builder As New AttributeTableBuilder()

            ' Apply the ReadOnlyAttribute to the Background property 
            ' of the Button class.
            builder.AddCustomAttributes(GetType(Button), "Background", New ReadOnlyAttribute(True))

            Dim attributes As AttributeTable = builder.CreateTable()

            Dim hasCustomAttributes As Boolean = attributes.ContainsAttributes(GetType(Button))

            Dim types As IEnumerable(Of Type) = attributes.AttributedTypes

            ' The following code shows how to retrieve custom attributes
            ' using the GetCustomAttributes method overloads.
            Dim attrs0 As IEnumerable = attributes.GetCustomAttributes(GetType(Button))

            Dim attrs1 As IEnumerable = attributes.GetCustomAttributes(GetType(Button), "Background")

            Return attributes
        End Get
    End Property
End Class
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using System.Text;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows;

using Microsoft.Windows.Design.Features;
using Microsoft.Windows.Design.Metadata;

// The ProvideMetadata assembly-level attribute indicates to designers
// that this assembly contains a class that provides an attribute table. 
[assembly: ProvideMetadata(typeof(CustomControlLibrary.VisualStudio.Design.Metadata))]
namespace CustomControlLibrary.VisualStudio.Design
{
    // Container for any general design-time metadata to initialize.
    // Designers look for a type in the design-time assembly that 
    // implements IProvideAttributeTable. If found, designers instantiate 
    // this class and access its AttributeTable property automatically.
    internal class Metadata : IProvideAttributeTable
    {
        // Accessed by the designer to register any design-time metadata.
        public AttributeTable AttributeTable
        {
            get
            {
                AttributeTableBuilder builder = new AttributeTableBuilder();

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

                AttributeTable attributes = builder.CreateTable();

                bool hasCustomAttributes = attributes.ContainsAttributes(typeof(Button));

                IEnumerable<Type> types = attributes.AttributedTypes;

                // The following code shows how to retrieve custom attributes
                // using the GetCustomAttributes method overloads.
                IEnumerable attrs0 = attributes.GetCustomAttributes(typeof(Button));

                IEnumerable attrs1 = attributes.GetCustomAttributes(
                    typeof(Button),
                    "Background");

                return attributes;
            }
        }
    }
}

Zabezpečení podprocesu

Všechny veřejné členy static (Shared v jazyce Visual Basic) tohoto typu jsou zabezpečeny pro používání podprocesů. Zabezpečení sdílených členů pro používání podprocesů není zaručeno.

Viz také

Odkaz

Microsoft.Windows.Design.Metadata – obor názvů

AttributeTableBuilder

Další zdroje

Poskytování metadata prvků Design