AttributeCallbackBuilder 클래스

이 클래스의 인스턴스는 형식의 특성을 나중에 채우는 콜백 대리자에 전달됩니다.

상속 계층 구조

System.Object
  Microsoft.Windows.Design.Metadata.AttributeCallbackBuilder

네임스페이스:  Microsoft.Windows.Design.Metadata
어셈블리:  Microsoft.Windows.Design.Extensibility(Microsoft.Windows.Design.Extensibility.dll)

구문

‘선언
Public NotInheritable Class AttributeCallbackBuilder
public sealed class AttributeCallbackBuilder
public ref class AttributeCallbackBuilder sealed
[<Sealed>]
type AttributeCallbackBuilder =  class end
public final class AttributeCallbackBuilder

AttributeCallbackBuilder 형식에서는 다음과 같은 멤버를 노출합니다.

속성

  이름 설명
Public 속성 CallbackType 이 콜백이 호출되는 형식을 가져옵니다.

위쪽

메서드

  이름 설명
Public 메서드 AddCustomAttributes(array<Attribute[]) 지정된 특성의 내용을 이 작성기에 추가합니다.
Public 메서드 AddCustomAttributes(String, array<Attribute[]) 지정된 이름의 멤버에 특성을 추가합니다.
Public 메서드 Equals 지정한 Object가 현재 Object와 같은지 여부를 확인합니다. (Object에서 상속됨)
Protected 메서드 Finalize 가비지 수집에서 회수하기 전에 개체에서 리소스를 해제하고 다른 정리 작업을 수행할 수 있게 합니다. (Object에서 상속됨)
Public 메서드 GetHashCode 특정 형식에 대한 해시 함수 역할을 합니다. (Object에서 상속됨)
Public 메서드 GetType 현재 인스턴스의 Type을 가져옵니다. (Object에서 상속됨)
Protected 메서드 MemberwiseClone 현재 Object의 단순 복사본을 만듭니다. (Object에서 상속됨)
Public 메서드 ToString 현재 개체를 나타내는 문자열을 반환합니다. (Object에서 상속됨)

위쪽

설명

AttributeCallbackBuilder를 사용하여 요청 시 AttributeTable을 채울 수 있습니다. 특성 테이블에 매우 많은 특성이 포함되는 경우 이렇게 해야 합니다. 형식에 특성을 몇 개만 지정하는 경우에는 AttributeTableBuilder만 사용합니다.

대리자 형식을 사용하면 디자이너에서 대상 형식의 메타데이터를 요청할 때까지 특성이 생성되지 않습니다. AttributeTableBuilder에서는 이 콜백 정보를 AttributeTable에 전송하여 보존합니다. 따라서 이러한 콜백 대리자는 요청 시에만 호출됩니다. 호출된 결과는 AttributeTable에서 캐시됩니다.

AddCallback 메서드를 사용하여 특성을 요청 시 생성합니다.

예제

다음 코드 예제에서는 AttributeCallbackBuilder 클래스를 사용하여 특성 테이블을 만들고 값을 채우는 방법을 보여 줍니다.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Reflection;
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();

                // Build the attribute table by using the AttributeCallbackBuilder 
                // class. The attribute table is not populated until the designer
                // needs it, which is more efficient for large attribute tables.
                builder.AddCallback(
                    typeof(Button),
                    delegate(AttributeCallbackBuilder callbackBuilder)
                    {
                        callbackBuilder.AddCustomAttributes(
                            new DefaultPropertyAttribute("Content"));

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

                return builder.CreateTable();
            }
        }
    }
}

스레드로부터의 안전성

이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

참고 항목

참조

Microsoft.Windows.Design.Metadata 네임스페이스

AttributeTableBuilder

AddCallback

AttributeTable

기타 리소스

연습: 디자인 타임 표시기 만들기