IMethodMessage.HasVarArgs プロパティ

定義

メッセージに可変個の引数があるかどうかを示す値を取得します。

public:
 property bool HasVarArgs { bool get(); };
public bool HasVarArgs { get; }
public bool HasVarArgs { [System.Security.SecurityCritical] get; }
member this.HasVarArgs : bool
[<get: System.Security.SecurityCritical>]
member this.HasVarArgs : bool
Public ReadOnly Property HasVarArgs As Boolean

プロパティ値

メソッドに可変個の引数を指定できる場合は true。それ以外の場合は false

属性

例外

即時呼び出し元は、インターフェイスへの参照を使用して呼び出しを行い、インフラストラクチャのアクセス許可はありません。

次のコード例は、メソッド呼び出しに可変引数があるかどうかを含め、メッセージ情報をコンソールに書き込むために をオーバーライド RealProxy.Invoke するカスタム プロキシを示しています。

// Overriding the Invoke method of RealProxy.
virtual IMessage^ Invoke( IMessage^ message ) override
{
   IMethodMessage^ myMethodMessage = dynamic_cast<IMethodMessage^>(message);
   Console::WriteLine( "**** Begin Invoke ****" );
   Console::WriteLine( "\tType is : {0}", myType );
   Console::WriteLine( "\tMethod name : {0}", myMethodMessage->MethodName );
   for ( int i = 0; i < myMethodMessage->ArgCount; i++ )
   {
      Console::WriteLine( "\tArgName is : {0}", myMethodMessage->GetArgName( i ) );
      Console::WriteLine( "\tArgValue is: {0}", myMethodMessage->GetArg( i ) );

   }
   if ( myMethodMessage->HasVarArgs )
         Console::WriteLine( "\t The method have variable arguments!!" );
   else
         Console::WriteLine( "\t The method does not have variable arguments!!" );

   
   // Dispatch the method call to the real Object*.
   Object^ returnValue = myType->InvokeMember( myMethodMessage->MethodName, BindingFlags::InvokeMethod, nullptr, myObjectInstance, myMethodMessage->Args );
   Console::WriteLine( "**** End Invoke ****" );
   
   // Build the return message to pass back to the transparent proxy.
   ReturnMessage^ myReturnMessage = gcnew ReturnMessage( returnValue,nullptr,0,nullptr,dynamic_cast<IMethodCallMessage^>(message) );
   return myReturnMessage;
}
// Overriding the Invoke method of RealProxy.
public override IMessage Invoke(IMessage message)
{
   IMethodMessage myMethodMessage = (IMethodMessage)message;

   Console.WriteLine("**** Begin Invoke ****");
   Console.WriteLine("\tType is : " + myType);
   Console.WriteLine("\tMethod name : " +  myMethodMessage.MethodName);

   for (int i=0; i < myMethodMessage.ArgCount; i++)
   {
      Console.WriteLine("\tArgName is : " + myMethodMessage.GetArgName(i));
      Console.WriteLine("\tArgValue is: " + myMethodMessage.GetArg(i));
   }

   if(myMethodMessage.HasVarArgs)
       Console.WriteLine("\t The method have variable arguments!!");
   else
       Console.WriteLine("\t The method does not have variable arguments!!");

   // Dispatch the method call to the real object.
   Object returnValue = myType.InvokeMember( myMethodMessage.MethodName, BindingFlags.InvokeMethod, null,
                                        myObjectInstance, myMethodMessage.Args );
   Console.WriteLine("**** End Invoke ****");

   // Build the return message to pass back to the transparent proxy.
   ReturnMessage myReturnMessage = new ReturnMessage( returnValue, null, 0, null,
       (IMethodCallMessage)message );
   return myReturnMessage;
}
' Overriding the Invoke method of RealProxy.
Public Overrides Function Invoke(message As IMessage) As IMessage
   Dim myMethodMessage As IMethodMessage = CType(message, IMethodMessage)
   
   Console.WriteLine("**** Begin Invoke ****")
   Console.WriteLine(ControlChars.Tab + "Type is : " + myType.ToString())
   Console.WriteLine(ControlChars.Tab + "Method name : " + myMethodMessage.MethodName)
   
   Dim i As Integer
   For i = 0 To myMethodMessage.ArgCount - 1
      Console.WriteLine(ControlChars.Tab + "ArgName is : " + myMethodMessage.GetArgName(i))
      Console.WriteLine(ControlChars.Tab + "ArgValue is: " + myMethodMessage.GetArg(i))
   Next i
   
   If myMethodMessage.HasVarArgs Then
      Console.WriteLine(ControlChars.Tab + " The method have variable arguments!!")
   Else
      Console.WriteLine(ControlChars.Tab + " The method does not have variable arguments!!")
   End If 
   ' Dispatch the method call to the real object.
   Dim returnValue As Object = myType.InvokeMember(myMethodMessage.MethodName, _
                  BindingFlags.InvokeMethod, Nothing, myObjectInstance, myMethodMessage.Args)
   Console.WriteLine("**** End Invoke ****")
   
   ' Build the return message to pass back to the transparent proxy.
   Dim myReturnMessage As New ReturnMessage(returnValue, Nothing, 0, Nothing, _
                                                      CType(message, IMethodCallMessage))
   Return myReturnMessage
End Function 'Invoke

適用対象