Assembly.IsDefinedとは? わかりやすく解説

Assembly.IsDefined メソッド

指定した属性アセンブリ適用されているかどうか示します

名前空間: System.Reflection
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Overridable Function
 IsDefined ( _
    attributeType As Type, _
    inherit As Boolean _
) As Boolean
Dim instance As Assembly
Dim attributeType As Type
Dim inherit As Boolean
Dim returnValue As Boolean

returnValue = instance.IsDefined(attributeType, inherit)
public virtual bool IsDefined (
    Type attributeType,
    bool inherit
)
public:
virtual bool IsDefined (
    Type^ attributeType, 
    bool inherit
)
public boolean IsDefined (
    Type attributeType, 
    boolean inherit
)
public function IsDefined (
    attributeType : Type, 
    inherit : boolean
) : boolean

パラメータ

attributeType

このアセンブリチェックする属性Type

inherit

この型のオブジェクトでは、この引数無視されます。

戻り値
属性アセンブリ適用されている場合trueそれ以外場合false

例外例外
例外種類条件

ArgumentNullException

attributeTypenull 参照 (Visual Basic では Nothing) です。

使用例使用例

属性定義しIsDefined使用して属性定義されたかどうかを示すコード例次に示します。このコード例では、定義されなかった属性調べます

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

' The output is:
' True
' False
'
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));
    }
}
//
//  The output is:
//  True
//  False
//
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

_Assembly.IsDefined メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

COM オブジェクトに、IsDefined メソッドへのバージョン依存しないアクセス用意されています。

このメソッドは、CLS準拠していません。  

名前空間: System.Runtime.InteropServices
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Function IsDefined ( _
    attributeType As Type, _
    inherit As Boolean _
) As Boolean
Dim instance As _Assembly
Dim attributeType As Type
Dim inherit As Boolean
Dim returnValue As Boolean

returnValue = instance.IsDefined(attributeType, inherit)
bool IsDefined (
    Type attributeType,
    bool inherit
)
bool IsDefined (
    Type^ attributeType, 
    bool inherit
)
boolean IsDefined (
    Type attributeType, 
    boolean inherit
)
function IsDefined (
    attributeType : Type, 
    inherit : boolean
) : boolean

パラメータ

attributeType

このアセンブリ確認するカスタム属性Type

inherit

この型のオブジェクトでは、この引数無視されます。

戻り値
指定されType識別されるカスタム属性定義されている場合trueそれ以外場合false

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

Assembly.IsDefinedのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Assembly.IsDefinedのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS