IMethodCallMessage.InArgs 属性

定义

获取未标记为 out 参数的参数数组。Gets an array of arguments that are not marked as out parameters.

public:
 property cli::array <System::Object ^> ^ InArgs { cli::array <System::Object ^> ^ get(); };
[get: System.Security.SecurityCritical]
public object[] InArgs { get; }
member this.InArgs : obj[]
Public ReadOnly Property InArgs As Object()

属性值

Object[]

未标记为 out 参数的参数数组。An array of arguments that are not marked as out parameters.

属性

异常

直接调用方通过引用接口进行调用,且没有基础结构权限。The immediate caller makes the call through a reference to the interface and does not have infrastructure permission.

示例

   virtual IMessage^ Invoke( IMessage^ myIMessage ) override
   {
      Console::WriteLine( "MyProxy::Invoke Start" );
      Console::WriteLine( "" );
      ReturnMessage^ myReturnMessage = nullptr;
      if ( dynamic_cast<IMethodCallMessage^>(myIMessage) )
      {
         Console::WriteLine( "Message is of type 'IMethodCallMessage*'." );
         Console::WriteLine( "" );
         IMethodCallMessage^ myIMethodCallMessage;
         myIMethodCallMessage = dynamic_cast<IMethodCallMessage^>(myIMessage);
         Console::WriteLine( "InArgCount is  : {0}", myIMethodCallMessage->InArgCount );
         IEnumerator^ myEnum = myIMethodCallMessage->InArgs->GetEnumerator();
         while ( myEnum->MoveNext() )
         {
            Object^ myObj = safe_cast<Object^>(myEnum->Current);
            Console::WriteLine( "InArgs is : {0}", myObj );
         }

         for ( int i = 0; i < myIMethodCallMessage->InArgCount; i++ )
         {
            Console::WriteLine( "GetArgName({0}) is : {1}", i, myIMethodCallMessage->GetArgName( i ) );
            Console::WriteLine( "GetInArg({0}) is : {0}", i, myIMethodCallMessage->GetInArg( i ) );

         }
         Console::WriteLine( "" );
      }
      else
      if ( dynamic_cast<IMethodReturnMessage^>(myIMessage) )
            Console::WriteLine( "Message is of type 'IMethodReturnMessage*'." );

      // Build Return Message 
      myReturnMessage = gcnew ReturnMessage( 5,nullptr,0,nullptr,dynamic_cast<IMethodCallMessage^>(myIMessage) );
      Console::WriteLine( "MyProxy::Invoke - Finish" );
      return myReturnMessage;
   }
};

// The class used to obtain Metadata.
public ref class MyMarshalByRefClass: public MarshalByRefObject
{
public:
   int MyMethod( String^ str, double dbl, int i )
   {
      Console::WriteLine( "MyMarshalByRefClass::MyMethod {0} {1} {2}", str, dbl, i );
      return 0;
   }

};

    public override IMessage Invoke(IMessage myIMessage)
    {
       Console.WriteLine("MyProxy.Invoke Start");
       Console.WriteLine("");
       ReturnMessage myReturnMessage = null;
       
       if (myIMessage is IMethodCallMessage)
       {
          Console.WriteLine("Message is of type 'IMethodCallMessage'.");
          Console.WriteLine("");

          IMethodCallMessage myIMethodCallMessage;
          myIMethodCallMessage=(IMethodCallMessage)myIMessage;
          Console.WriteLine("InArgCount is  : " + 
                            myIMethodCallMessage.InArgCount.ToString());
       
          foreach (object myObj in myIMethodCallMessage.InArgs)
          {
             Console.WriteLine("InArgs is : " + myObj.ToString());
          }

          for(int i=0; i<myIMethodCallMessage.InArgCount; i++)
          {
             Console.WriteLine("GetArgName(" +i.ToString() +") is : " + 
                                     myIMethodCallMessage.GetArgName(i));
             Console.WriteLine("GetInArg("+i.ToString() +") is : " +
                            myIMethodCallMessage.GetInArg(i).ToString());
          }
          Console.WriteLine("");
       }
       else if (myIMessage is IMethodReturnMessage)
          Console.WriteLine("Message is of type 'IMethodReturnMessage'.");
                
       // Build Return Message
       myReturnMessage = new ReturnMessage(5,null,0,null,
                                     (IMethodCallMessage)myIMessage);
    
       Console.WriteLine("MyProxy.Invoke - Finish");
       return myReturnMessage;
    }


 }

 
 // The class used to obtain Metadata.
 [PermissionSet(SecurityAction.Demand, Name="FullTrust")]
 public class MyMarshalByRefClass : MarshalByRefObject
 {
    public int MyMethod(string str, double dbl, int i)
    {
       Console.WriteLine("MyMarshalByRefClass.MyMethod {0} {1} {2}", str, dbl, i);
       return 0;
    }
 }
   Public Overrides Function Invoke(ByVal myIMessage As IMessage) As IMessage
      Console.WriteLine("MyProxy.Invoke Start")
      Console.WriteLine("")

      If TypeOf myIMessage Is IMethodCallMessage Then
         Console.WriteLine("Message is of type 'IMethodCallMessage'.")
         Console.WriteLine("")

         Dim myIMethodCallMessage As IMethodCallMessage
         myIMethodCallMessage = CType(myIMessage, IMethodCallMessage)

         Console.WriteLine("InArgCount is : " + myIMethodCallMessage.InArgCount.ToString)
         Dim myObj As Object
         For Each myObj In myIMethodCallMessage.InArgs
            Console.WriteLine("InArgs is : " + myObj.ToString())
         Next

         Dim i As Integer
         For i = 0 To myIMethodCallMessage.InArgCount - 1
            Console.WriteLine("GetArgName(" + i.ToString() + ") is : " + myIMethodCallMessage.GetArgName(i))
            Console.WriteLine("GetInArg(" + i.ToString() + ") is : " + myIMethodCallMessage.GetInArg(i).ToString)
         Next i

         Console.WriteLine("")
      ElseIf TypeOf myIMessage Is IMethodReturnMessage Then
         Console.WriteLine("Message is of type 'IMethodReturnMessage'.")
      End If

      ' Build Return Message
      Dim myReturnMessage As New ReturnMessage(5, Nothing, 0, Nothing, _
                                 CType(myIMessage, IMethodCallMessage))

      Console.WriteLine("MyProxy.Invoke - Finish")
      Return myReturnMessage

   End Function 'Invoke



End Class

' The class used to obtain Metadata.
<PermissionSet(SecurityAction.Demand, Name:="FullTrust")> _
Public Class MyMarshalByRefClass
   Inherits MarshalByRefObject

   Public Function MyMethod(ByVal str As String, ByVal dbl As Double, ByVal i As Integer) As Integer
      Console.WriteLine("MyMarshalByRefClass.MyMethod {0} {1} {2}", str, dbl, i)
      Return 0
   End Function 'MyMethod
End Class

注解

尽管属性是冗余的, 但InArgCount使用和GetInArg方法可以实现相同的功能, 但如果实施者理解所有参数都将InArgs获得.Although the InArgs property is redundant since the same functionality can be achieved with the InArgCount and GetInArg methods, there might be performance optimization available if the implementer understands when all the arguments will be retrieved.

安全性

SecurityPermission
用于处理基础结构代码。for operating with infrastructure code. 要求值: LinkDemand;权限值:InfrastructureDemand value: LinkDemand; Permission value: Infrastructure

适用于