Assembly.IsDefined メソッド
アセンブリ: 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)
戻り値
属性がアセンブリに適用されている場合は true。それ以外の場合は false。


属性を定義し、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 //

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


_Assembly.IsDefined メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As _Assembly Dim attributeType As Type Dim inherit As Boolean Dim returnValue As Boolean returnValue = instance.IsDefined(attributeType, inherit)
戻り値
指定された Type で識別されるカスタム属性が定義されている場合は true。それ以外の場合は false。


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Assembly.IsDefinedのページへのリンク