渡された MethodInfo を使用して LogicalMethodInfo クラスの新しいインスタンスを初期化します。
Public Sub New( _
ByVal methodInfo As MethodInfo _)
[C#]
public LogicalMethodInfo(
MethodInfomethodInfo);
[C++]
public: LogicalMethodInfo(
MethodInfo* methodInfo);
[JScript]
public function LogicalMethodInfo(
methodInfo : MethodInfo);
パラメータ
- methodInfo
MethodInfo に共通の LogicalMethodInfo のプロパティを初期化する MethodInfo 。
例外
| 例外の種類 | 条件 |
|---|---|
| InvalidOperationException | methodInfo パラメータの MethodBase.IsStatic プロパティが true です。
または methodInfo パラメータの MethodBase.GetParameters メソッドに、 LogicalMethodInfo のインスタンスが表すメソッドで必要とされるすべてのパラメータは格納されていません。 |
使用例
Imports System
Imports System.Reflection
Imports System.Web.Services.Protocols
Imports Microsoft.VisualBasic
Public Class MyService
Public Function Add(xValue As Integer, yValue As Integer) As Integer
Return xValue + yValue
End Function 'Add
End Class 'MyService
Public Class LogicalMethodInfo_Constructor
Public Shared Sub Main()
Dim myType As Type = GetType(MyService)
Dim myMethodInfo As MethodInfo = myType.GetMethod("Add")
Dim myLogicalMethodInfo As New LogicalMethodInfo(myMethodInfo)
Console.WriteLine(ControlChars.NewLine + "Printing properties of method : {0}" + _
ControlChars.NewLine, myLogicalMethodInfo.ToString())
Console.WriteLine(ControlChars.NewLine + "The declaring type of the method {0} is :" + _
ControlChars.NewLine, myLogicalMethodInfo.Name)
Console.WriteLine(ControlChars.Tab + myLogicalMethodInfo.DeclaringType.ToString())
Console.WriteLine(ControlChars.NewLine + "The parameters of the method {0} are :" + _
ControlChars.NewLine, myLogicalMethodInfo.Name)
Dim myParameters As ParameterInfo() = myLogicalMethodInfo.Parameters
Dim i As Integer
For i = 0 To myParameters.Length - 1
Console.WriteLine(ControlChars.Tab + myParameters(i).Name + " : " + _
myParameters(i).ParameterType.ToString())
Next i
Console.WriteLine(ControlChars.NewLine + "The return type of the method {0} is :" + _
ControlChars.NewLine, myLogicalMethodInfo.Name)
Console.WriteLine(ControlChars.Tab + myLogicalMethodInfo.ReturnType.ToString())
Dim service As New MyService()
Console.WriteLine(ControlChars.NewLine + "Invoking the method {0}" + _
ControlChars.NewLine, myLogicalMethodInfo.Name)
Console.WriteLine(ControlChars.Tab + "The sum of 10 and 10 is : {0}", _
myLogicalMethodInfo.Invoke(service, New Object() {10, 10}))
End Sub 'Main
End Class 'LogicalMethodInfo_Constructor
[C#]
using System;
using System.Reflection;
using System.Web.Services.Protocols;
public class MyService
{
public int Add(int xValue, int yValue)
{
return (xValue + yValue);
}
}
public class LogicalMethodInfo_Constructor
{
public static void Main()
{
Type myType = typeof(MyService);
MethodInfo myMethodInfo = myType.GetMethod("Add");
LogicalMethodInfo myLogicalMethodInfo =
new LogicalMethodInfo(myMethodInfo);
Console.WriteLine("\nPrinting properties of method : {0}\n",
myLogicalMethodInfo.ToString());
Console.WriteLine("\nThe declaring type of the method {0} is :\n",
myLogicalMethodInfo.Name);
Console.WriteLine("\t" + myLogicalMethodInfo.DeclaringType);
Console.WriteLine("\nThe parameters of the method {0} are :\n",
myLogicalMethodInfo.Name);
ParameterInfo[] myParameters = myLogicalMethodInfo.Parameters;
for(int i = 0; i < myParameters.Length; i++)
{
Console.WriteLine("\t" + myParameters[i].Name +
" : " + myParameters[i].ParameterType);
}
Console.WriteLine("\nThe return type of the method {0} is :\n",
myLogicalMethodInfo.Name);
Console.WriteLine("\t" + myLogicalMethodInfo.ReturnType);
MyService service = new MyService();
Console.WriteLine("\nInvoking the method {0}\n",
myLogicalMethodInfo.Name);
Console.WriteLine("\tThe sum of 10 and 10 is : {0}",
myLogicalMethodInfo.Invoke(service,
new object[] {10, 10}));
}
}
[C++]
#using <mscorlib.dll>
#using <System.Web.Services.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::Web::Services::Protocols;
public __gc class MyService {
public:
int Add(int xValue, int yValue) {
return (xValue + yValue);
}
};
int main() {
Type* myType = __typeof(MyService);
MethodInfo* myMethodInfo = myType->GetMethod(S"Add");
LogicalMethodInfo* myLogicalMethodInfo =
new LogicalMethodInfo(myMethodInfo);
Console::WriteLine(S"\nPrinting properties of method : {0}\n",
myLogicalMethodInfo);
Console::WriteLine(S"\nThe declaring type of the method {0} is :\n",
myLogicalMethodInfo->Name);
Console::WriteLine(S"\t {0}", myLogicalMethodInfo->DeclaringType);
Console::WriteLine(S"\nThe parameters of the method {0} are :\n",
myLogicalMethodInfo->Name);
ParameterInfo* myParameters[] = myLogicalMethodInfo->Parameters;
for (int i = 0; i < myParameters->Length; i++) {
Console::WriteLine(S"\t {0}",String::Concat(myParameters[i]->Name,
S" : ", myParameters[i]->ParameterType));
}
Console::WriteLine(S"\nThe return type of the method {0} is :\n",
myLogicalMethodInfo->Name);
Console::WriteLine(S"\t {0}", myLogicalMethodInfo->ReturnType);
MyService* service = new MyService();
Console::WriteLine(S"\nInvoking the method {0}\n",
myLogicalMethodInfo->Name);
Object * values __gc[] = new Object * [2];
values[0] = __box(10);
values[1] = __box(10);
Console::WriteLine(S"\tThe sum of 10 and 10 is : {0}",
myLogicalMethodInfo->Invoke(service,values));
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン
をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
LogicalMethodInfo クラス | LogicalMethodInfo メンバ | System.Web.Services.Protocols 名前空間