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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="CodeMemberMethod.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 a class method.
  28.     /// </para>
  29.     /// </devdoc>
  30.     [ClassInterface(ClassInterfaceType.AutoDispatch), ComVisible(true), Serializable()]
  31.     public class CodeMemberMethod : CodeTypeMember
  32.     {
  33.         private CodeParameterDeclarationExpressionCollection parameters = new CodeParameterDeclarationExpressionCollection();
  34.         private CodeStatementCollection statements = new CodeStatementCollection();
  35.         private CodeTypeReference returnType;
  36.         private CodeTypeReference privateImplements = null;
  37.         private CodeTypeReferenceCollection implementationTypes = null;
  38.         private CodeAttributeDeclarationCollection returnAttributes = null;
  39.        
  40.         [OptionalField()]
  41.         private CodeTypeParameterCollection typeParameters;
  42.        
  43.         private int populated = 0;
  44.         private const int ParametersCollection = 1;
  45.         private const int StatementsCollection = 2;
  46.         private const int ImplTypesCollection = 4;
  47.        
  48.         /// <devdoc>
  49.         /// <para>
  50.         /// An event that will be fired the first time the Parameters Collection is accessed.
  51.         /// </para>
  52.         /// </devdoc>
  53.         public event EventHandler PopulateParameters;
  54.        
  55.         /// <devdoc>
  56.         /// <para>
  57.         /// An event that will be fired the first time the Statements Collection is accessed.
  58.         /// </para>
  59.         /// </devdoc>
  60.         public event EventHandler PopulateStatements;
  61.        
  62.         /// <devdoc>
  63.         /// <para>
  64.         /// An event that will be fired the first time the ImplementationTypes Collection is accessed.
  65.         /// </para>
  66.         /// </devdoc>
  67.         public event EventHandler PopulateImplementationTypes;
  68.        
  69.         /// <devdoc>
  70.         /// <para>
  71.         /// Gets or sets the return type of the method.
  72.         /// </para>
  73.         /// </devdoc>
  74.         public CodeTypeReference ReturnType {
  75.             get {
  76.                 if (returnType == null) {
  77.                     returnType = new CodeTypeReference(typeof(void).FullName);
  78.                 }
  79.                 return returnType;
  80.             }
  81.             set { returnType = value; }
  82.         }
  83.        
  84.         /// <devdoc>
  85.         /// <para>
  86.         /// Gets or sets the statements within the method.
  87.         /// </para>
  88.         /// </devdoc>
  89.         public CodeStatementCollection Statements {
  90.             get {
  91.                 if (0 == (populated & StatementsCollection)) {
  92.                     populated |= StatementsCollection;
  93.                     if (PopulateStatements != null)
  94.                         PopulateStatements(this, EventArgs.Empty);
  95.                 }
  96.                 return statements;
  97.             }
  98.         }
  99.        
  100.         /// <devdoc>
  101.         /// <para>
  102.         /// Gets or sets the parameter declarations for the method.
  103.         /// </para>
  104.         /// </devdoc>
  105.         public CodeParameterDeclarationExpressionCollection Parameters {
  106.             get {
  107.                 if (0 == (populated & ParametersCollection)) {
  108.                     populated |= ParametersCollection;
  109.                     if (PopulateParameters != null)
  110.                         PopulateParameters(this, EventArgs.Empty);
  111.                 }
  112.                 return parameters;
  113.             }
  114.         }
  115.        
  116.         /// <devdoc>
  117.         /// <para>[To be supplied.]</para>
  118.         /// </devdoc>
  119.         public CodeTypeReference PrivateImplementationType {
  120.             get { return privateImplements; }
  121.             set { privateImplements = value; }
  122.         }
  123.        
  124.         /// <devdoc>
  125.         /// <para>[To be supplied.]</para>
  126.         /// </devdoc>
  127.         public CodeTypeReferenceCollection ImplementationTypes {
  128.             get {
  129.                 if (implementationTypes == null) {
  130.                     implementationTypes = new CodeTypeReferenceCollection();
  131.                 }
  132.                
  133.                 if (0 == (populated & ImplTypesCollection)) {
  134.                     populated |= ImplTypesCollection;
  135.                     if (PopulateImplementationTypes != null)
  136.                         PopulateImplementationTypes(this, EventArgs.Empty);
  137.                 }
  138.                 return implementationTypes;
  139.             }
  140.         }
  141.        
  142.         /// <devdoc>
  143.         /// <para>[To be supplied.]</para>
  144.         /// </devdoc>
  145.         public CodeAttributeDeclarationCollection ReturnTypeCustomAttributes {
  146.             get {
  147.                 if (returnAttributes == null) {
  148.                     returnAttributes = new CodeAttributeDeclarationCollection();
  149.                 }
  150.                 return returnAttributes;
  151.             }
  152.         }
  153.        
  154.         [System.Runtime.InteropServices.ComVisible(false)]
  155.         public CodeTypeParameterCollection TypeParameters {
  156.             get {
  157.                 if (typeParameters == null) {
  158.                     typeParameters = new CodeTypeParameterCollection();
  159.                 }
  160.                
  161.                 return typeParameters;
  162.             }
  163.         }
  164.     }
  165. }

Developer Fusion