Поделиться через


FeatureAttribute - класс

Обновлен: Ноябрь 2007

Хранит объект Type, представляющий тип FeatureProvider.

Пространство имен:  Microsoft.Windows.Design.Features
Сборка:  Microsoft.Windows.Design.Extensibility (в Microsoft.Windows.Design.Extensibility.dll)

Синтаксис

'Декларация
<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Interface, AllowMultiple := True)> _
Public NotInheritable Class FeatureAttribute _
    Inherits Attribute
'Применение
Dim instance As FeatureAttribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple = true)]
public sealed class FeatureAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Interface, AllowMultiple = true)]
public ref class FeatureAttribute sealed : public Attribute
public final class FeatureAttribute extends Attribute

Заметки

Атрибут FeatureAttribute используется для присоединения функций времени конструирования к типу.

При необходимости конструктор создает экземпляр поставщика функций, заданного этим атрибутом. Дополнительные сведения см. в разделе Поставщики функций и соединительные элементы.

Примеры

В следующем примере показано, как создать FeatureAttribute для связи поставщика декоративного элемента с классом управления. Дополнительные сведения см. в разделе Пошаговое руководство. Создание графического элемента времени разработки.

' Container for any general design-time metadata to initialize.
' Designers look for a type in the design-time assembly that 
' implements IRegisterMetadata. If found, designers instantiate 
' this class and call its Register() method automatically.
Friend Class Metadata
    Implements IRegisterMetadata

    ' Called by the designer to register any design-time metadata.
    Public Sub Register() Implements IRegisterMetadata.Register
        Dim builder As New AttributeTableBuilder()

        ' Add the adorner provider to the design-time metadata.
        builder.AddCustomAttributes(GetType(ButtonWithDesignTime), _
                                    New FeatureAttribute(GetType(OpacitySliderAdornerProvider)))

        MetadataStore.AddAttributeTable(builder.CreateTable())
    End Sub

End Class
// Container for any general design-time metadata to initialize.
// Designers look for a type in the design-time assembly that 
// implements IRegisterMetadata. If found, designers instantiate 
// this class and call its Register() method automatically.
internal class Metadata : IRegisterMetadata
{
    // Called by the designer to register any design-time metadata.
    public void Register()
    {
        AttributeTableBuilder builder = new AttributeTableBuilder();

        // Add the adorner provider to the design-time metadata.
        builder.AddCustomAttributes(
            typeof(ButtonWithDesignTime), 
            new FeatureAttribute(typeof(OpacitySliderAdornerProvider)));

        MetadataStore.AddAttributeTable(builder.CreateTable());
    }
}

Иерархия наследования

System.Object
  System.Attribute
    Microsoft.Windows.Design.Features.FeatureAttribute

Потокобезопасность

Любые открытые члены этого типа, объявленные как static (Shared в Visual Basic), являются потокобезопасными. Потокобезопасность членов экземпляров не гарантируется.

См. также

Ссылки

FeatureAttribute - члены

Microsoft.Windows.Design.Features - пространство имен

FeatureProvider

Другие ресурсы

Поставщики функций и соединительные элементы