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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="codemethodreferenceexpression.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.     using System.Runtime.Serialization;
  24.    
  25.     /// <devdoc>
  26.     /// <para>
  27.     /// Represents an
  28.     /// expression to invoke a method, to be called on a given target.
  29.     /// </para>
  30.     /// </devdoc>
  31.     [ClassInterface(ClassInterfaceType.AutoDispatch), ComVisible(true), Serializable()]
  32.     public class CodeMethodReferenceExpression : CodeExpression
  33.     {
  34.         private CodeExpression targetObject;
  35.         private string methodName;
  36.         [OptionalField()]
  37.         private CodeTypeReferenceCollection typeArguments;
  38.        
  39.         /// <devdoc>
  40.         /// <para>
  41.         /// Initializes a new instance of <see cref='System.CodeDom.CodeMethodReferenceExpression'/>.
  42.         /// </para>
  43.         /// </devdoc>
  44.         public CodeMethodReferenceExpression()
  45.         {
  46.         }
  47.        
  48.         /// <devdoc>
  49.         /// <para>
  50.         /// Initializes a new instance of <see cref='System.CodeDom.CodeMethodReferenceExpression'/> using the specified
  51.         /// target object and method name.
  52.         /// </para>
  53.         /// </devdoc>
  54.         public CodeMethodReferenceExpression(CodeExpression targetObject, string methodName)
  55.         {
  56.             TargetObject = targetObject;
  57.             MethodName = methodName;
  58.         }
  59.        
  60.         public CodeMethodReferenceExpression(CodeExpression targetObject, string methodName, params CodeTypeReference[] typeParameters)
  61.         {
  62.             TargetObject = targetObject;
  63.             MethodName = methodName;
  64.             if (typeParameters != null && typeParameters.Length > 0) {
  65.                 TypeArguments.AddRange(typeParameters);
  66.             }
  67.         }
  68.        
  69.         /// <devdoc>
  70.         /// <para>
  71.         /// Gets or sets the target object.
  72.         /// </para>
  73.         /// </devdoc>
  74.         public CodeExpression TargetObject {
  75.             get { return targetObject; }
  76.             set { this.targetObject = value; }
  77.         }
  78.        
  79.         /// <devdoc>
  80.         /// <para>
  81.         /// Gets or sets the name of the method to invoke.
  82.         /// </para>
  83.         /// </devdoc>
  84.         public string MethodName {
  85.             get { return (methodName == null) ? string.Empty : methodName; }
  86.             set { methodName = value; }
  87.         }
  88.        
  89.         [System.Runtime.InteropServices.ComVisible(false)]
  90.         public CodeTypeReferenceCollection TypeArguments {
  91.             get {
  92.                 if (typeArguments == null) {
  93.                     typeArguments = new CodeTypeReferenceCollection();
  94.                 }
  95.                 return typeArguments;
  96.             }
  97.         }
  98.     }
  99. }

Developer Fusion