MethodBase.IsAssembly プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)


設定されている場合、このメソッドは同じアセンブリの異なるクラスから呼び出すことができます。
MethodBase を取得するには、最初に型を取得します。型からメソッドを取得します。メソッドから MethodBase を取得します。MethodBase またはコンストラクタがパブリックでない場合は、それらは保護されているため簡単にはアクセスできません。パブリックでないメソッドにアクセスするには、GetMethod で BindingFlags マスクを NonPublic に設定します。

指定したメソッドが同一アセンブリ内の他のクラスから呼び出すことのできるメソッドかどうかを調べ、その結果を表示します。
Imports System Imports System.Reflection Imports Microsoft.VisualBasic Class methodbase1 Friend Sub f() End Sub Public Shared Function Main() As Integer Console.WriteLine(ControlChars.CrLf + "Reflection.MethodBase") 'Get the types. Dim MyType1 As Type = _ Type.GetType("System.Runtime.Serialization.Formatter") Dim MyType2 As Type = _ Type.GetType("methodbase1") ' Get and display the methods and the IsAssembly property value. Dim Mymethodbase1 As MethodBase = _ MyType1.GetMethod("WriteInt32", BindingFlags.NonPublic Or BindingFlags.Instance) Dim Mymethodbase2 As MethodBase = _ MyType2.GetMethod("f", BindingFlags.NonPublic Or BindingFlags.Instance) Console.Write(ControlChars.CrLf _ + "Mymethodbase = " + Mymethodbase1.ToString()) If Mymethodbase1.IsAssembly Then Console.Write(ControlChars.CrLf _ + "Mymethodbase is an assembly method.") Else Console.Write(ControlChars.CrLf _ + "Mymethodbase is not an assembly method.") End If Console.Write(ControlChars.CrLf + ControlChars.CrLf _ + "Mymethodbase = " + Mymethodbase2.ToString()) If Mymethodbase2.IsAssembly Then Console.Write(ControlChars.CrLf + _ "Mymethodbase is an assembly method.") Else Console.Write(ControlChars.CrLf + _ "Mymethodbase is not an assembly method.") End If Return 0 End Function End Class
using System; using System.Reflection; class methodbase { internal void f() { } public static int Main(string[] args) { Console.WriteLine ("\nReflection.MethodBase"); // Get the MethodBase of two methods. // Get the types. Type MyType1 = Type.GetType("System.Runtime.Serialization.Formatter"); Type MyType2 = Type.GetType("methodbase"); // Get and display the methods and the IsAssembly property value. MethodBase Mymethodbase1 = MyType1.GetMethod("WriteInt32",BindingFlags.NonPublic|BindingFlags.Instance); MethodBase Mymethodbase2 = MyType2.GetMethod("f", BindingFlags.NonPublic|BindingFlags.Instance); Console.Write("\nMymethodbase = " + Mymethodbase1.ToString()); if (Mymethodbase1.IsAssembly) Console.Write ("\nMymethodbase is an assembly method."); else Console.Write ("\nMymethodbase is not an assembly method."); Console.Write("\n\nMymethodbase = " + Mymethodbase2.ToString()); if (Mymethodbase2.IsAssembly) Console.Write ("\nMymethodbase is an assembly method."); else Console.Write ("\nMymethodbase is not an assembly method."); return 0; } }
using namespace System; using namespace System::Reflection; public ref class methodbase { public private: void f(){} }; int main() { Console::WriteLine( "\nReflection.MethodBase" ); // Get the MethodBase of two methods. // Get the types. Type^ MyType1 = Type::GetType( "System.Runtime.Serialization.Formatter" ); Type^ MyType2 = Type::GetType( "methodbase" ); // Get and display the methods and the IsAssembly property value. MethodBase^ Mymethodbase1 = MyType1->GetMethod( "WriteInt32", static_cast<BindingFlags>(BindingFlags::NonPublic | BindingFlags::Instance) ); MethodBase^ Mymethodbase2 = MyType2->GetMethod( "f", static_cast<BindingFlags>(BindingFlags::NonPublic | BindingFlags::Instance) ); Console::Write( "\nMymethodbase = {0}", Mymethodbase1 ); if ( Mymethodbase1->IsAssembly ) Console::Write( "\nMymethodbase is an assembly method." ); else Console::Write( "\nMymethodbase is not an assembly method." ); Console::Write( "\n\nMymethodbase = {0}", Mymethodbase2 ); if ( Mymethodbase2->IsAssembly ) Console::Write( "\nMymethodbase is an assembly method." ); else Console::Write( "\nMymethodbase is not an assembly method." ); return 0; }
import System.*; import System.Reflection.*; class Methodbase { void F() { } //F public static void main(String[] args) { Console.WriteLine("\nReflection.MethodBase"); // Get the MethodBase of two methods. // Get the types. Type myType1 = Type.GetType("System.Runtime.Serialization.Formatter"); Type myType2 = Type.GetType("Methodbase"); // Get and display the methods and the IsAssembly property value. MethodBase myMethodBase1 = myType1.GetMethod("WriteInt32", BindingFlags.NonPublic | BindingFlags.Instance); MethodBase myMethodBase2 = myType2.GetMethod("F", BindingFlags.NonPublic | BindingFlags.Instance| BindingFlags.Public); Console.Write(("\nmyMethodBase = " + myMethodBase1.ToString())); if ( myMethodBase1.get_IsAssembly() ) { Console.Write("\nmyMethodBase is an assembly method."); } else { Console.Write("\nmyMethodBase is not an assembly method."); } Console.Write(("\n\nmyMethodBase = " + myMethodBase2.ToString())); if ( myMethodBase2.get_IsAssembly() ) { Console.Write("\nmyMethodBase is an assembly method."); } else { Console.Write("\nmyMethodBase is not an assembly method."); } } //main } //methodbase

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


_MethodBase.IsAssembly プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)

同じアセンブリの異なるクラスからこのメソッドを呼び出すことができる場合は true。それ以外の場合は false。

このプロパティは、アンマネージ コードからマネージ クラスにアクセスするためのプロパティであるため、マネージ コードからは呼び出さないでください。
IsAssembly プロパティは、このメソッドを同じアセンブリ内の他のクラスから呼び出すことができるかどうかを示す値を取得します。

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- MethodBase.IsAssemblyのページへのリンク