次の方法で共有


LogicalMethodInfo.Create メソッド (MethodInfo , LogicalMethodTypes)

返される LogicalMethodInfo の配列を非同期メソッドまたは同期メソッドだけに制限できる MethodInfo の指定配列に基づいて、 LogicalMethodInfo の配列を作成します。

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

パラメータ

  • methodInfos
    LogicalMethodInfo オブジェクトを作成する対象の同期メソッドおよび非同期メソッドを表す MethodInfo の配列。
  • types
    LogicalMethodTypes 値のビットごとの組み合わせ。返された LogicalMethodInfo 配列に、非同期メソッドまたは同期メソッドのどちらかだけが格納されているか、または両方が格納されているかを判断します。

戻り値

types の値でフィルタ処理された methodInfos, 内のメソッドを表す LogicalMethodInfo の配列。

例外

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

使用例

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

Public Class MyService
   Inherits SoapHttpClientProtocol
   
   Public Function BeginAdd _
       (xValue As Integer, yValue As Integer, callback As AsyncCallback, asyncState As Object) _
                                                                                    As IAsyncResult
      Return Me.BeginInvoke("Add", New Object() {xValue, yValue}, callback, asyncState)
   End Function 'BeginAdd
   
   Public Function EndAdd(asyncResult As System.IAsyncResult) As Integer
      Dim results As Object() = Me.EndInvoke(asyncResult)
      Return CInt(results(0))
   End Function 'EndAdd
End Class 'MyService

Public Class LogicalMethodInfo_Create
   
   Public Shared Sub Main()
      Dim myType As Type = GetType(MyService)
      Dim myBeginMethod As MethodInfo = myType.GetMethod("BeginAdd")
      Dim myEndMethod As MethodInfo = myType.GetMethod("EndAdd")
      Dim myLogicalMethodInfo As LogicalMethodInfo = _
          LogicalMethodInfo.Create(New MethodInfo() _
                          {myBeginMethod, myEndMethod}, LogicalMethodTypes.Async)(0)
      
      Console.WriteLine _
        (ControlChars.Newline + "The asynchronous callback parameter of method {0} is :" + _ 
                                             ControlChars.Newline, myLogicalMethodInfo.Name)
      Console.WriteLine _
        (ControlChars.Tab + myLogicalMethodInfo.AsyncCallbackParameter.Name + " : " + _
                    myLogicalMethodInfo.AsyncCallbackParameter.ParameterType.ToString())
      
      Console.WriteLine _
        (ControlChars.Newline + "The asynchronous state parameter of method {0} is :" + _
                                             ControlChars.Newline, myLogicalMethodInfo.Name)
      Console.WriteLine _
       (ControlChars.Tab + myLogicalMethodInfo.AsyncStateParameter.Name + " : " + _
                               myLogicalMethodInfo.AsyncStateParameter.ParameterType.ToString())
      
      Console.WriteLine _
       (ControlChars.Newline + "The asynchronous result parameter of method {0} is :" + _
                                                     ControlChars.Newline, myLogicalMethodInfo.Name)
      Console.WriteLine _
       (ControlChars.Tab + myLogicalMethodInfo.AsyncResultParameter.Name + " : " + _
                               myLogicalMethodInfo.AsyncResultParameter.ParameterType.ToString())
      
      Console.WriteLine _
        (ControlChars.Newline + "The begin method of the asynchronous method {0} is :" + _
                                             ControlChars.Newline, myLogicalMethodInfo.Name)
      Console.WriteLine(ControlChars.Tab + myLogicalMethodInfo.BeginMethodInfo.ToString())
      
      Console.WriteLine _
       (ControlChars.Newline + "The end method of the asynchronous method {0} is :" + _
                                                     ControlChars.Newline, myLogicalMethodInfo.Name)
      Console.WriteLine(ControlChars.Tab + myLogicalMethodInfo.EndMethodInfo.ToString())
      
      If myLogicalMethodInfo.IsAsync Then
         Console.WriteLine(ControlChars.Newline + "{0} is asynchronous", myLogicalMethodInfo.Name)
      Else
         Console.WriteLine(ControlChars.Newline + "{0} is synchronous", myLogicalMethodInfo.Name)
      End If 
   End Sub 'Main
End Class 'LogicalMethodInfo_Create

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

public class MyService : SoapHttpClientProtocol
{
   public IAsyncResult BeginAdd(int xValue, int yValue,
                                AsyncCallback callback,
                                object asyncState)
   {
      return this.BeginInvoke("Add", new object[] {xValue,yValue}, callback, asyncState);
   }

   public int EndAdd(System.IAsyncResult asyncResult) 
   {
      object[] results = this.EndInvoke(asyncResult);
      return ((int)(results[0]));
   } 
}

public class LogicalMethodInfo_Create
{
   public static void Main()
   {
      Type myType = typeof(MyService);
      MethodInfo myBeginMethod = myType.GetMethod("BeginAdd");
      MethodInfo myEndMethod = myType.GetMethod("EndAdd");
      LogicalMethodInfo myLogicalMethodInfo = 
         (LogicalMethodInfo.Create(new MethodInfo[] { myBeginMethod,
                                                      myEndMethod },
                                   LogicalMethodTypes.Async))[0];

      Console.WriteLine("\nThe asynchronous callback parameter of method {0} is :\n",
                           myLogicalMethodInfo.Name);
      Console.WriteLine("\t" + myLogicalMethodInfo.AsyncCallbackParameter.Name +
                              " : " + myLogicalMethodInfo.AsyncCallbackParameter.ParameterType);

            Console.WriteLine("\nThe asynchronous state parameter of method {0} is :\n",
         myLogicalMethodInfo.Name);
      Console.WriteLine("\t" + myLogicalMethodInfo.AsyncStateParameter.Name +
         " : " + myLogicalMethodInfo.AsyncStateParameter.ParameterType);

      Console.WriteLine("\nThe asynchronous result parameter of method {0} is :\n",
         myLogicalMethodInfo.Name);
      Console.WriteLine("\t" + myLogicalMethodInfo.AsyncResultParameter.Name +
         " : " + myLogicalMethodInfo.AsyncResultParameter.ParameterType);

      Console.WriteLine("\nThe begin method of the asynchronous method {0} is :\n",
         myLogicalMethodInfo.Name);
      Console.WriteLine("\t" + myLogicalMethodInfo.BeginMethodInfo);

      Console.WriteLine("\nThe end method of the asynchronous method {0} is :\n",
         myLogicalMethodInfo.Name);
      Console.WriteLine("\t" + myLogicalMethodInfo.EndMethodInfo);

      if(myLogicalMethodInfo.IsAsync)
         Console.WriteLine("\n{0} is asynchronous", myLogicalMethodInfo.Name);
      else
         Console.WriteLine("\n{0} is synchronous", myLogicalMethodInfo.Name);

   }
}

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

public __gc class MyService : public SoapHttpClientProtocol {
public:
   IAsyncResult* BeginAdd(int xValue, int yValue,
      AsyncCallback* callback,
      Object* asyncState) {

         Object* temp0 [] = {__box(xValue), __box(yValue)};

         return this->BeginInvoke(S"Add", temp0, callback, asyncState);
      }

public:
   int EndAdd(System::IAsyncResult* asyncResult) {
      Object* results[] = this->EndInvoke(asyncResult);
      return *dynamic_cast<int __gc *>(results[0]);
   }
};

int main() {
   Type*  myType = __typeof(MyService);
   MethodInfo*  myBeginMethod = myType->GetMethod(S"BeginAdd");
   MethodInfo*  myEndMethod = myType->GetMethod(S"EndAdd");
   MethodInfo* temp0 [] = {myBeginMethod, myEndMethod};
   LogicalMethodInfo* myLogicalMethodInfo = 
      LogicalMethodInfo::Create(temp0, LogicalMethodTypes::Async)[0];

   Console::WriteLine(S"\nThe asynchronous callback parameter of method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0} : {1}", myLogicalMethodInfo->AsyncCallbackParameter->Name,
      myLogicalMethodInfo->AsyncCallbackParameter->ParameterType);

   Console::WriteLine(S"\nThe asynchronous state parameter of method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0} : {1}", myLogicalMethodInfo->AsyncStateParameter->Name,
      myLogicalMethodInfo->AsyncStateParameter->ParameterType);

   Console::WriteLine(S"\nThe asynchronous result parameter of method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0} : {1}", myLogicalMethodInfo->AsyncResultParameter->Name,
      myLogicalMethodInfo->AsyncResultParameter->ParameterType);

   Console::WriteLine(S"\nThe begin method of the asynchronous method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0}", myLogicalMethodInfo->BeginMethodInfo);

   Console::WriteLine(S"\nThe end method of the asynchronous method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0}", myLogicalMethodInfo->EndMethodInfo);

   if (myLogicalMethodInfo->IsAsync)
      Console::WriteLine(S"\n {0} is asynchronous", 
      myLogicalMethodInfo->Name);
   else
      Console::WriteLine(S"\n {0} is synchronous", 
      myLogicalMethodInfo->Name);
}

[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