Assembly.IsDefined(Type, Boolean) Method

Definition

지정된 특성이 어셈블리에 적용되었는지를 나타냅니다.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

Parameters

attributeType
Type

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

inherit
Boolean

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

Returns

Boolean

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

Implements

Exceptions

attributeType이(가) null인 경우attributeType is null.

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

Examples

다음 코드 예제에서는 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.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
'

Applies to