LogicalMethodInfo.Create Method (MethodInfo[], LogicalMethodTypes)
.NET Framework 3.0
Given an array of MethodInfo, where the returned array of LogicalMethodInfo can be restricted to only asynchronous or synchronous methods, creates an array of LogicalMethodInfo.
Namespace: System.Web.Services.Protocols
Assembly: System.Web.Services (in system.web.services.dll)
Assembly: System.Web.Services (in system.web.services.dll)
public: static array<LogicalMethodInfo^>^ Create ( array<MethodInfo^>^ methodInfos, LogicalMethodTypes types )
public static LogicalMethodInfo[] Create ( MethodInfo[] methodInfos, LogicalMethodTypes types )
public static function Create ( methodInfos : MethodInfo[], types : LogicalMethodTypes ) : LogicalMethodInfo[]
Not applicable.
Parameters
- methodInfos
An array of MethodInfo representing the asynchronous and synchronous methods for which to create LogicalMethodInfo objects.
- types
A bitwise combination of the LogicalMethodTypes values. Determines whether just asynchronous or synchronous methods or both are included in the returned array of LogicalMethodInfo.
Return Value
An array of LogicalMethodInfo, representing the methods within methodInfos, filtered by the value of types.#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 ); }
import System.*;
import System.Reflection.*;
import System.Web.Services.Protocols.*;
public class MyService extends SoapHttpClientProtocol
{
public IAsyncResult BeginAdd(int xValue, int yValue, AsyncCallback callback,
Object asyncState)
{
return this.BeginInvoke("Add", new Object[] { (Int32)xValue,
(Int32)yValue }, callback, asyncState);
} //BeginAdd
public int EndAdd(System.IAsyncResult asyncResult)
{
Object results[] = this.EndInvoke(asyncResult);
return Convert.ToInt32(results.get_Item(0));
} //EndAdd
} //MyService
public class LogicalMethodInfo_Create
{
public static void main(String[] args)
{
Type myType = MyService.class.ToType();
MethodInfo myBeginMethod = myType.GetMethod("BeginAdd");
MethodInfo myEndMethod = myType.GetMethod("EndAdd");
LogicalMethodInfo myLogicalMethodInfo =
((LogicalMethodInfo)((LogicalMethodInfo[])LogicalMethodInfo.
Create(new MethodInfo[] { myBeginMethod, myEndMethod },
LogicalMethodTypes.Async)).get_Item(0));
Console.WriteLine("\nThe asynchronous callback parameter "
+ "of method {0} is :\n", myLogicalMethodInfo.get_Name());
Console.WriteLine("\t"
+ myLogicalMethodInfo.get_AsyncCallbackParameter().get_Name()
+ " : " + myLogicalMethodInfo.get_AsyncCallbackParameter().
get_ParameterType());
Console.WriteLine("\nThe asynchronous state parameter "
+ "of method {0} is :\n", myLogicalMethodInfo.get_Name());
Console.WriteLine("\t"
+ myLogicalMethodInfo.get_AsyncStateParameter().get_Name() + " : "
+ myLogicalMethodInfo.get_AsyncStateParameter().
get_ParameterType());
Console.WriteLine("\nThe asynchronous result parameter "
+ "of method {0} is :\n", myLogicalMethodInfo.get_Name());
Console.WriteLine("\t"
+ myLogicalMethodInfo.get_AsyncResultParameter().get_Name() + " : "
+ myLogicalMethodInfo.get_AsyncResultParameter().
get_ParameterType());
Console.WriteLine("\nThe begin method of the asynchronous "
+ "method {0} is :\n", myLogicalMethodInfo.get_Name());
Console.WriteLine("\t" + myLogicalMethodInfo.get_BeginMethodInfo());
Console.WriteLine("\nThe end method of the asynchronous "
+ "method {0} is :\n", myLogicalMethodInfo.get_Name());
Console.WriteLine("\t" + myLogicalMethodInfo.get_EndMethodInfo());
if (myLogicalMethodInfo.get_IsAsync()) {
Console.WriteLine("\n{0} is asynchronous",
myLogicalMethodInfo.get_Name());
}
else {
Console.WriteLine("\n{0} is synchronous",
myLogicalMethodInfo.get_Name());
}
} //main
} //LogicalMethodInfo_Create
Windows 98, Windows Server 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
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: