AmbientValueAttribute 클래스

정의

속성이 다른 소스에서 값을 가져오도록 속성에 전달할 값을 지정합니다. 이를 앰비언스라고 합니다. 이 클래스는 상속될 수 없습니다.

public ref class AmbientValueAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class AmbientValueAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
type AmbientValueAttribute = class
    inherit Attribute
Public NotInheritable Class AmbientValueAttribute
Inherits Attribute
상속
AmbientValueAttribute
특성

예제

다음 코드 예제에서는 사용 하 여 AmbientValueAttribute 라는 AlertForeColor속성에 대 한 주변 동작을 적용 하는 방법을 보여 줍니다. 전체 코드 목록은 참조 하세요 방법: Windows Forms 컨트롤에서 특성 적용합니다.

[AmbientValue(typeof(Color), "Empty")]
[Category("Appearance")]
[DefaultValue(typeof(Color), "White")]
[Description("The color used for painting alert text.")]
public Color AlertForeColor
{
    get
    {
        if (this.alertForeColorValue == Color.Empty &&
            this.Parent != null)
        {
            return Parent.ForeColor;
        }

        return this.alertForeColorValue;
    }

    set
    {
        this.alertForeColorValue = value;
    }
}

// This method is used by designers to enable resetting the
// property to its default value.
public void ResetAlertForeColor()
{
    this.AlertForeColor = AttributesDemoControl.defaultAlertForeColorValue;
}

// This method indicates to designers whether the property
// value is different from the ambient value, in which case
// the designer should persist the value.
private bool ShouldSerializeAlertForeColor()
{
    return (this.alertForeColorValue != AttributesDemoControl.ambientColorValue);
}
<AmbientValue(GetType(Color), "Empty"), _
Category("Appearance"), _
DefaultValue(GetType(Color), "White"), _
Description("The color used for painting alert text.")> _
Public Property AlertForeColor() As Color
    Get
        If Me.alertForeColorValue = Color.Empty AndAlso (Me.Parent IsNot Nothing) Then
            Return Parent.ForeColor
        End If

        Return Me.alertForeColorValue
    End Get

    Set(ByVal value As Color)
        Me.alertForeColorValue = value
    End Set
End Property

' This method is used by designers to enable resetting the
' property to its default value.
Public Sub ResetAlertForeColor()
    Me.AlertForeColor = AttributesDemoControl.defaultAlertForeColorValue
End Sub

' This method indicates to designers whether the property
' value is different from the ambient value, in which case
' the designer should persist the value.
Private Function ShouldSerializeAlertForeColor() As Boolean
    Return Me.alertForeColorValue <> AttributesDemoControl.ambientColorValue
End Function

설명

컨트롤의 속성에 주변 동작이 있는 경우 이 특성이 있어야 합니다. 앰비언트 속성은 부모 값(예: 속성 또는 속성)을 Control.FontControl.BackColor 쿼리합니다.

일반적으로 시각적 디자이너는 특성을 사용하여 속성에 AmbientValueAttribute 유지할 값을 결정합니다. 이는 일반적으로 속성이 다른 원본에서 해당 값을 가져오는 값입니다. 앰비언트 값의 예는 Color.Empty 속성의 앰비언트 값입니다 BackColor . 폼에 컨트롤이 있고 컨트롤의 속성이 폼의 속성과 BackColor 다른 색 BackColor 으로 설정된 경우 컨트롤의 을 로 설정하여 컨트롤의 속성을 폼의 속성으로 다시 BackColor 설정할 BackColorColor.Empty수 있습니다.

생성자

AmbientValueAttribute(Boolean)

해당 값에 대해 부울 값을 지정하여 AmbientValueAttribute 클래스의 새 인스턴스를 초기화합니다.

AmbientValueAttribute(Byte)

해당 값에 대해 8비트 부호 없는 정수를 지정하여 AmbientValueAttribute 클래스의 새 인스턴스를 초기화합니다.

AmbientValueAttribute(Char)

해당 값에 대해 유니코드 문자를 지정하여 AmbientValueAttribute 클래스의 새 인스턴스를 초기화합니다.

AmbientValueAttribute(Double)

해당 값에 대해 배정밀도 부동 소수점 숫자를 지정하여 AmbientValueAttribute 클래스의 새 인스턴스를 초기화합니다.

AmbientValueAttribute(Int16)

해당 값에 대해 16비트 부호 있는 정수를 지정하여 AmbientValueAttribute 클래스의 새 인스턴스를 초기화합니다.

AmbientValueAttribute(Int32)

해당 값에 대해 32비트 부호 있는 정수를 지정하여 AmbientValueAttribute 클래스의 새 인스턴스를 초기화합니다.

AmbientValueAttribute(Int64)

해당 값에 대해 64비트 부호 있는 정수를 지정하여 AmbientValueAttribute 클래스의 새 인스턴스를 초기화합니다.

AmbientValueAttribute(Object)

해당 값에 대해 개체를 지정하여 AmbientValueAttribute 클래스의 새 인스턴스를 초기화합니다.

AmbientValueAttribute(Single)

해당 값에 대해 단정밀도 부동 소수점 숫자를 지정하여 AmbientValueAttribute 클래스의 새 인스턴스를 초기화합니다.

AmbientValueAttribute(String)

해당 값에 대해 문자열을 지정하여 AmbientValueAttribute 클래스의 새 인스턴스를 초기화합니다.

AmbientValueAttribute(Type, String)

값 및 형식을 지정하여 AmbientValueAttribute 클래스의 새 인스턴스를 초기화합니다.

속성

TypeId

파생 클래스에서 구현된 경우 이 Attribute에 대한 고유 식별자를 가져옵니다.

(다음에서 상속됨 Attribute)
Value

AmbientValueAttribute의 값인 개체를 가져옵니다.

메서드

Equals(Object)

지정한 AmbientValueAttribute가 현재 AmbientValueAttribute와 같은지 여부를 확인합니다.

GetHashCode()

이 인스턴스의 해시 코드를 반환합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IsDefaultAttribute()

파생 클래스에서 재정의된 경우 이 인스턴스 값이 파생 클래스에 대한 기본값인지 여부를 표시합니다.

(다음에서 상속됨 Attribute)
Match(Object)

파생 클래스에서 재정의된 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

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

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 Attribute)

적용 대상