次の方法で共有


LogicalMethodInfo.Create メソッド (MethodInfo )

非同期メソッドと同期メソッドの両方に関する情報を格納できる MethodInfo の指定配列に基づいて LogicalMethodInfo の配列を作成します。

Overloads Public Shared Function Create( _
   ByVal methodInfos() As MethodInfo _) As LogicalMethodInfo()
[C#]
public static LogicalMethodInfo[] Create(MethodInfo[] methodInfos);
[C++]
public: static LogicalMethodInfo* Create(MethodInfo* methodInfos[]) [];
[JScript]
public static function Create(
   methodInfos : MethodInfo[]) : LogicalMethodInfo[];

パラメータ

  • methodInfos
    LogicalMethodInfo オブジェクトを作成する対象の同期メソッドおよび非同期メソッドを表す MethodInfo の配列。

戻り値

methodInfos 内のメソッドを表す LogicalMethodInfo の配列。

例外

例外の種類 条件
InvalidOperationException Begin 非同期メソッドは methodInfos に格納されていますが、対応する End メソッドがありません。

使用例

 
Imports System
Imports System.Reflection
Imports System.Web.Services.Protocols
Imports Microsoft.VisualBasic

Public Class MyService
   
   Public Sub MyMethod(inParameter As Integer, ByRef outParameter As Integer)
      outParameter = inParameter
   End Sub 'MyMethod
End Class 'MyService

Public Class LogicalMethodInfo_Create
   
   Public Shared Sub Main()
      Dim myType As Type = GetType(MyService)
      Dim myMethodInfo As MethodInfo = myType.GetMethod("MyMethod")
      Dim myLogicalMethodInfo As LogicalMethodInfo = _
                             LogicalMethodInfo.Create(New MethodInfo() {myMethodInfo})(0)
      
      Console.WriteLine _
        (ControlChars.Newline + "Printing parameters for the method : {0}", myLogicalMethodInfo.Name)
      
      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 in parameters of the method {0} are :" + _
                                               ControlChars.Newline, myLogicalMethodInfo.Name)
      myParameters = myLogicalMethodInfo.InParameters

      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 out parameters of the method {0} are :" + _
                                                    ControlChars.Newline, myLogicalMethodInfo.Name)
      myParameters = myLogicalMethodInfo.OutParameters

      For i = 0 To myParameters.Length - 1
         Console.WriteLine(ControlChars.Tab + myParameters(i).Name + " : " + _
                                                     myParameters(i).ParameterType.toString())
      Next i
      
      If myLogicalMethodInfo.IsVoid Then
         Console.WriteLine(ControlChars.Newline + "The return type is void")
      Else
         Console.WriteLine _
             (ControlChars.Newline + "The return type is {0}", myLogicalMethodInfo.ReturnType)
      End If
   End Sub 'Main 
End Class 'LogicalMethodInfo_Create

[C#] 
using System;
using System.Reflection;
using System.Web.Services.Protocols;

public class MyService
{
   public void MyMethod(int inParameter, out int outParameter)
   {
      outParameter = inParameter;
   }
}

public class LogicalMethodInfo_Create
{
   public static void Main()
   {
      Type myType = typeof(MyService);
      MethodInfo myMethodInfo = myType.GetMethod("MyMethod");
      LogicalMethodInfo myLogicalMethodInfo = 
         (LogicalMethodInfo.Create(new MethodInfo[] {myMethodInfo}))[0];

      Console.WriteLine("\nPrinting parameters for the method : {0}",
                           myLogicalMethodInfo.Name);

      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 in parameters of the method {0} are :\n",
         myLogicalMethodInfo.Name);
      myParameters = myLogicalMethodInfo.InParameters;
      for(int i = 0; i < myParameters.Length; i++)
      {
         Console.WriteLine("\t" + myParameters[i].Name +
            " : " + myParameters[i].ParameterType);
      }

      Console.WriteLine("\nThe out parameters of the method {0} are :\n",
         myLogicalMethodInfo.Name);
      myParameters = myLogicalMethodInfo.OutParameters;
      for(int i = 0; i < myParameters.Length; i++)
      {
         Console.WriteLine("\t" + myParameters[i].Name +
            " : " + myParameters[i].ParameterType);
      }

      if(myLogicalMethodInfo.IsVoid)
         Console.WriteLine("\nThe return type is void");
      else
         Console.WriteLine("\nThe return type is {0}",
                                 myLogicalMethodInfo.ReturnType);

   }
}

[C++] 
#using <mscorlib.dll>
#using <System.Web.Services.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
using namespace System::Reflection;
using namespace System::Web::Services::Protocols;

public __gc class MyService {
public:
   void MyMethod(int inParameter, [Out] int __gc * outParameter) {
      *outParameter = inParameter;
   }
};

int main() {
   Type*  myType = __typeof(MyService);

   MethodInfo* myMethodInfo = myType->GetMethod(S"MyMethod");
   MethodInfo * temparray[] = { myMethodInfo};
   LogicalMethodInfo* myLogicalMethodInfo = 
      ( LogicalMethodInfo::Create(temparray))[0];

   Console::WriteLine(S"\nPrinting parameters for the method : {0}",
      myLogicalMethodInfo->Name);

   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(String::Concat(S"\t ", myParameters[i]->Name,
         S" : ", myParameters[i]->ParameterType));
   }

   Console::WriteLine(S"\nThe in parameters of the method {0} are :\n",
      myLogicalMethodInfo->Name);
   myParameters = myLogicalMethodInfo->InParameters;
   for (int i = 0; i < myParameters->Length; i++) {
      Console::WriteLine(String::Concat(S"\t ", myParameters[i]->Name,
         S" : ", myParameters[i]->ParameterType));
   }

   Console::WriteLine(S"\nThe out parameters of the method {0} are :\n",
      myLogicalMethodInfo->Name);
   myParameters = myLogicalMethodInfo->OutParameters;
   for (int i = 0; i < myParameters->Length; i++) {
      Console::WriteLine(String::Concat(S"\t ", myParameters[i]->Name,
         S" : ", myParameters[i]->ParameterType));
   }

   if (myLogicalMethodInfo->IsVoid)
      Console::WriteLine(S"\nThe return type is void");
   else
      Console::WriteLine(S"\nThe return type is {0}",
      myLogicalMethodInfo->ReturnType);
}

[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 ファミリ

参照

LogicalMethodInfo クラス | LogicalMethodInfo メンバ | System.Web.Services.Protocols 名前空間 | LogicalMethodInfo.Create オーバーロードの一覧 | MethodInfo