The Labs \ Source Viewer \ SSCLI \ System.CodeDom \ CodeMethodInvokeExpression

  1. //------------------------------------------------------------------------------
  2. // <copyright file="CodeMethodInvokeExpression.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.CodeDom
  16. {
  17.    
  18.     using System.Diagnostics;
  19.     using System;
  20.     using Microsoft.Win32;
  21.     using System.Collections;
  22.     using System.Runtime.InteropServices;
  23.    
  24.     /// <devdoc>
  25.     /// <para>
  26.     /// Represents an
  27.     /// expression to invoke a method, to be called on a given target.
  28.     /// </para>
  29.     /// </devdoc>
  30.     [ClassInterface(ClassInterfaceType.AutoDispatch), ComVisible(true), Serializable()]
  31.     public class CodeMethodInvokeExpression : CodeExpression
  32.     {
  33.         private CodeMethodReferenceExpression method;
  34.         private CodeExpressionCollection parameters = new CodeExpressionCollection();
  35.        
  36.         /// <devdoc>
  37.         /// <para>
  38.         /// Initializes a new instance of <see cref='System.CodeDom.CodeMethodInvokeExpression'/>.
  39.         /// </para>
  40.         /// </devdoc>
  41.         public CodeMethodInvokeExpression()
  42.         {
  43.         }
  44.        
  45.         /// <devdoc>
  46.         /// <para>
  47.         /// Initializes a new instance of <see cref='System.CodeDom.CodeMethodInvokeExpression'/> using the specified target object, method name
  48.         /// and parameters.
  49.         /// </para>
  50.         /// </devdoc>
  51.         public CodeMethodInvokeExpression(CodeMethodReferenceExpression method, params CodeExpression[] parameters)
  52.         {
  53.             this.method = method;
  54.             Parameters.AddRange(parameters);
  55.         }
  56.        
  57.         /// <devdoc>
  58.         /// <para>[To be supplied.]</para>
  59.         /// </devdoc>
  60.         public CodeMethodInvokeExpression(CodeExpression targetObject, string methodName, params CodeExpression[] parameters)
  61.         {
  62.             this.method = new CodeMethodReferenceExpression(targetObject, methodName);
  63.             Parameters.AddRange(parameters);
  64.         }
  65.        
  66.         /// <devdoc>
  67.         /// <para>
  68.         /// Gets or sets the name of the method to invoke.
  69.         /// </para>
  70.         /// </devdoc>
  71.         public CodeMethodReferenceExpression Method {
  72.             get {
  73.                 if (method == null) {
  74.                     method = new CodeMethodReferenceExpression();
  75.                 }
  76.                 return method;
  77.             }
  78.             set { method = value; }
  79.         }
  80.        
  81.         /// <devdoc>
  82.         /// <para>
  83.         /// Gets or sets
  84.         /// the parameters to invoke the method with.
  85.         /// </para>
  86.         /// </devdoc>
  87.         public CodeExpressionCollection Parameters {
  88.             get { return parameters; }
  89.         }
  90.     }
  91. }

Developer Fusion