Assembly.IsDefined(Type, Boolean) Assembly.IsDefined(Type, Boolean) Assembly.IsDefined(Type, Boolean) Assembly.IsDefined(Type, Boolean) Method

정의

지정된 특성이 어셈블리에 적용되었는지를 나타냅니다.Indicates whether or not a specified attribute has been applied to the assembly.

public:
 virtual bool IsDefined(Type ^ attributeType, bool inherit);
public virtual bool IsDefined (Type attributeType, bool inherit);
abstract member IsDefined : Type * bool -> bool
override this.IsDefined : Type * bool -> bool
Public Overridable Function IsDefined (attributeType As Type, inherit As Boolean) As Boolean

매개 변수

attributeType
Type Type Type Type

이 어셈블리에 대해 확인할 특성의 형식입니다.The type of the attribute to be checked for this assembly.

inherit
Boolean Boolean Boolean Boolean

이 인수는 이 형식의 개체에 대해 무시됩니다.This argument is ignored for objects of this type.

반환

특성이 어셈블리에 적용되었으면 true이고, 그렇지 않으면 false입니다.true if the attribute has been applied to the assembly; otherwise, false.

구현

예외

attributeTypenull입니다.attributeType is null.

attributeType이 잘못된 형식을 사용합니다.attributeType uses an invalid type.

예제

적용 하는 다음 코드 예제는 AssemblyTitleAttribute 어셈블리로 사용 하 여 다음 특성 IsDefined 정책이 적용 되었는지 여부를 나타냅니다.The following code example applies the AssemblyTitleAttribute attribute to an assembly and then uses IsDefined to indicate whether it was applied. 또한 적용 되지 않은 특성을 테스트 합니다.It also tests an attribute that was not applied.

using System;
using System.Reflection;

// Set an assembly attribute.
[assembly:AssemblyTitleAttribute("A title example")]


// Note that the suffix "Attribute" can be omitted:
// [assembly:AssemblyTitle("A title example")]


public class Test {

    public static void Main() {

        // Get the assembly that is executing this method.
        Assembly asm = Assembly.GetCallingAssembly();

        // Get the attribute type just defined.
        Type aType = typeof(AssemblyTitleAttribute);
        Console.WriteLine(asm.IsDefined(aType, false));

        // Try an attribute not defined.
        aType = typeof(AssemblyVersionAttribute);
        Console.WriteLine(asm.IsDefined(aType, false));
    }
}
//
//  This code example produces the following output:
//  True
//  False
//

Imports System
Imports System.Reflection

' Set an assembly attribute.
<Assembly:AssemblyTitleAttribute("A title example")>

' Note that the suffix "Attribute" can be omitted:
' <Assembly:AssemblyTitle("A title examle")>

Public Class Test
    Public Shared Sub Main()

        ' Get the assembly that is executing this method.
        Dim asm As [Assembly] = [Assembly].GetCallingAssembly

        ' Get the attribute type just defined.
        Dim aType As Type = GetType(AssemblyTitleAttribute)

        Console.WriteLine(asm.IsDefined(aType, false))

        ' Try an attribute not defined.
        aType = GetType(AssemblyVersionAttribute)

        Console.WriteLine(asm.IsDefined(aType, false))

    End Sub
End Class

' This code example produces the following output:
' True
' False
'

적용 대상