Udostępnij za pośrednictwem


LogicalMethodInfo.Create Metoda

Definicja

Biorąc pod uwagę tablicę , MethodInfotworzy tablicę .LogicalMethodInfo

Przeciążenia

Create(MethodInfo[])

Biorąc pod uwagę tablicęMethodInfo, która może zawierać informacje o metodach asynchronicznych i synchronicznych, tworzy tablicę .LogicalMethodInfo

Create(MethodInfo[], LogicalMethodTypes)

Biorąc pod uwagę tablicę , MethodInfow której zwracana tablica LogicalMethodInfo może być ograniczona tylko do metod asynchronicznych lub synchronicznych, tworzy tablicę .LogicalMethodInfo

Create(MethodInfo[])

Biorąc pod uwagę tablicęMethodInfo, która może zawierać informacje o metodach asynchronicznych i synchronicznych, tworzy tablicę .LogicalMethodInfo

public:
 static cli::array <System::Web::Services::Protocols::LogicalMethodInfo ^> ^ Create(cli::array <System::Reflection::MethodInfo ^> ^ methodInfos);
public:
 static cli::array <System::Web::Services::Protocols::LogicalMethodInfo ^> ^ Create(cli::array <System::Reflection::MethodInfo ^> ^ method_infos);
public static System.Web.Services.Protocols.LogicalMethodInfo[] Create (System.Reflection.MethodInfo[] methodInfos);
public static System.Web.Services.Protocols.LogicalMethodInfo[] Create (System.Reflection.MethodInfo[] method_infos);
static member Create : System.Reflection.MethodInfo[] -> System.Web.Services.Protocols.LogicalMethodInfo[]
static member Create : System.Reflection.MethodInfo[] -> System.Web.Services.Protocols.LogicalMethodInfo[]
Public Shared Function Create (methodInfos As MethodInfo()) As LogicalMethodInfo()
Public Shared Function Create (method_infos As MethodInfo()) As LogicalMethodInfo()

Parametry

methodInfosmethod_infos
MethodInfo[]

Tablica MethodInfo reprezentująca metody asynchroniczne i synchroniczne, dla których można tworzyć LogicalMethodInfo obiekty.

Zwraca

LogicalMethodInfo[]

Tablica , LogicalMethodInforeprezentująca metody w obiekcie methodInfos.

Wyjątki

Metoda Begin asynchroniczna jest uwzględniana bez methodInfos odpowiedniej End metody.

Przykłady

#using <System.Web.Services.dll>

using namespace System;
using namespace System::Runtime::InteropServices;
using namespace System::Reflection;
using namespace System::Web::Services::Protocols;

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

int main()
{
   Type^ myType = MyService::typeid;
   MethodInfo^ myMethodInfo = myType->GetMethod( "MyMethod" );
   array<MethodInfo^>^temparray = {myMethodInfo};
   LogicalMethodInfo^ myLogicalMethodInfo = (LogicalMethodInfo::Create( temparray ))[ 0 ];
   Console::WriteLine( "\nPrinting parameters for the method : {0}", myLogicalMethodInfo->Name );
   Console::WriteLine( "\nThe parameters of the method {0} are :\n", myLogicalMethodInfo->Name );
   array<ParameterInfo^>^myParameters = myLogicalMethodInfo->Parameters;
   for ( int i = 0; i < myParameters->Length; i++ )
   {
      Console::WriteLine( String::Concat( "\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( String::Concat( "\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( String::Concat( "\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 );
}
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);
   }
}
Imports System.Reflection
Imports System.Web.Services.Protocols

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

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
End Class

Zobacz też

Dotyczy

Create(MethodInfo[], LogicalMethodTypes)

Biorąc pod uwagę tablicę , MethodInfow której zwracana tablica LogicalMethodInfo może być ograniczona tylko do metod asynchronicznych lub synchronicznych, tworzy tablicę .LogicalMethodInfo

public:
 static cli::array <System::Web::Services::Protocols::LogicalMethodInfo ^> ^ Create(cli::array <System::Reflection::MethodInfo ^> ^ methodInfos, System::Web::Services::Protocols::LogicalMethodTypes types);
public:
 static cli::array <System::Web::Services::Protocols::LogicalMethodInfo ^> ^ Create(cli::array <System::Reflection::MethodInfo ^> ^ method_infos, System::Web::Services::Protocols::LogicalMethodTypes types);
public static System.Web.Services.Protocols.LogicalMethodInfo[] Create (System.Reflection.MethodInfo[] methodInfos, System.Web.Services.Protocols.LogicalMethodTypes types);
public static System.Web.Services.Protocols.LogicalMethodInfo[] Create (System.Reflection.MethodInfo[] method_infos, System.Web.Services.Protocols.LogicalMethodTypes types);
static member Create : System.Reflection.MethodInfo[] * System.Web.Services.Protocols.LogicalMethodTypes -> System.Web.Services.Protocols.LogicalMethodInfo[]
static member Create : System.Reflection.MethodInfo[] * System.Web.Services.Protocols.LogicalMethodTypes -> System.Web.Services.Protocols.LogicalMethodInfo[]
Public Shared Function Create (methodInfos As MethodInfo(), types As LogicalMethodTypes) As LogicalMethodInfo()
Public Shared Function Create (method_infos As MethodInfo(), types As LogicalMethodTypes) As LogicalMethodInfo()

Parametry

methodInfosmethod_infos
MethodInfo[]

Tablica MethodInfo reprezentująca metody asynchroniczne i synchroniczne, dla których można tworzyć LogicalMethodInfo obiekty.

types
LogicalMethodTypes

Bitowa kombinacja LogicalMethodTypes wartości. Określa, czy metody asynchroniczne lub synchroniczne, czy oba są uwzględniane w zwracanej tablicy .LogicalMethodInfo

Zwraca

LogicalMethodInfo[]

Tablica , LogicalMethodInforeprezentująca metody w programie methodInfos, filtrowana według wartości types.

Wyjątki

Metoda Begin asynchroniczna jest uwzględniana bez methodInfos odpowiedniej End metody.

Przykłady

#using <System.dll>
#using <System.Web.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>

using namespace System;
using namespace System::Reflection;
using namespace System::Web::Services::Protocols;

public ref class MyService: public SoapHttpClientProtocol
{
public:
   IAsyncResult^ BeginAdd( int xValue, int yValue, AsyncCallback^ callback, Object^ asyncState )
   {
      array<Object^>^temp0 = {xValue,yValue};
      return this->BeginInvoke( "Add", temp0, callback, asyncState );
   }

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

int main()
{
   Type^ myType = MyService::typeid;
   MethodInfo^ myBeginMethod = myType->GetMethod( "BeginAdd" );
   MethodInfo^ myEndMethod = myType->GetMethod( "EndAdd" );
   array<MethodInfo^>^temp0 = {myBeginMethod,myEndMethod};
   LogicalMethodInfo^ myLogicalMethodInfo = LogicalMethodInfo::Create( temp0, LogicalMethodTypes::Async )[ 0 ];
   Console::WriteLine( "\nThe asynchronous callback parameter of method {0} is :\n", myLogicalMethodInfo->Name );
   Console::WriteLine( "\t {0} : {1}", myLogicalMethodInfo->AsyncCallbackParameter->Name, myLogicalMethodInfo->AsyncCallbackParameter->ParameterType );
   Console::WriteLine( "\nThe asynchronous state parameter of method {0} is :\n", myLogicalMethodInfo->Name );
   Console::WriteLine( "\t {0} : {1}", myLogicalMethodInfo->AsyncStateParameter->Name, myLogicalMethodInfo->AsyncStateParameter->ParameterType );
   Console::WriteLine( "\nThe asynchronous result parameter of method {0} is :\n", myLogicalMethodInfo->Name );
   Console::WriteLine( "\t {0} : {1}", myLogicalMethodInfo->AsyncResultParameter->Name, myLogicalMethodInfo->AsyncResultParameter->ParameterType );
   Console::WriteLine( "\nThe begin method of the asynchronous method {0} is :\n", myLogicalMethodInfo->Name );
   Console::WriteLine( "\t {0}", myLogicalMethodInfo->BeginMethodInfo );
   Console::WriteLine( "\nThe end method of the asynchronous method {0} is :\n", myLogicalMethodInfo->Name );
   Console::WriteLine( "\t {0}", myLogicalMethodInfo->EndMethodInfo );
   if ( myLogicalMethodInfo->IsAsync )
      Console::WriteLine( "\n {0} is asynchronous", myLogicalMethodInfo->Name );
   else
      Console::WriteLine( "\n {0} is synchronous", myLogicalMethodInfo->Name );
}
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);
   }
}
Imports System.Reflection
Imports System.Web.Services.Protocols

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

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
End Class

Zobacz też

Dotyczy