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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="CodeMemberProperty.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 a class property.
  27.     /// </para>
  28.     /// </devdoc>
  29.     [ClassInterface(ClassInterfaceType.AutoDispatch), ComVisible(true), Serializable()]
  30.     public class CodeMemberProperty : CodeTypeMember
  31.     {
  32.         private CodeTypeReference type;
  33.         private CodeParameterDeclarationExpressionCollection parameters = new CodeParameterDeclarationExpressionCollection();
  34.         private bool hasGet;
  35.         private bool hasSet;
  36.         private CodeStatementCollection getStatements = new CodeStatementCollection();
  37.         private CodeStatementCollection setStatements = new CodeStatementCollection();
  38.         private CodeTypeReference privateImplements = null;
  39.         private CodeTypeReferenceCollection implementationTypes = null;
  40.        
  41.         /// <devdoc>
  42.         /// <para>[To be supplied.]</para>
  43.         /// </devdoc>
  44.         public CodeTypeReference PrivateImplementationType {
  45.             get { return privateImplements; }
  46.             set { privateImplements = value; }
  47.         }
  48.        
  49.         /// <devdoc>
  50.         /// <para>[To be supplied.]</para>
  51.         /// </devdoc>
  52.         public CodeTypeReferenceCollection ImplementationTypes {
  53.             get {
  54.                 if (implementationTypes == null) {
  55.                     implementationTypes = new CodeTypeReferenceCollection();
  56.                 }
  57.                 return implementationTypes;
  58.             }
  59.         }
  60.        
  61.         /// <devdoc>
  62.         /// <para>Gets or sets the data type of the property.</para>
  63.         /// </devdoc>
  64.         public CodeTypeReference Type {
  65.             get {
  66.                 if (type == null) {
  67.                     type = new CodeTypeReference("");
  68.                 }
  69.                 return type;
  70.             }
  71.             set { type = value; }
  72.         }
  73.        
  74.         /// <devdoc>
  75.         /// <para>
  76.         /// Gets a value
  77.         /// indicating whether the property has a get method accessor.
  78.         /// </para>
  79.         /// </devdoc>
  80.         public bool HasGet {
  81.             get { return hasGet || getStatements.Count > 0; }
  82.             set {
  83.                 hasGet = value;
  84.                 if (!value) {
  85.                     getStatements.Clear();
  86.                 }
  87.             }
  88.         }
  89.        
  90.         /// <devdoc>
  91.         /// <para>
  92.         /// Gets a value
  93.         /// indicating whether the property has a set method accessor.
  94.         /// </para>
  95.         /// </devdoc>
  96.         public bool HasSet {
  97.             get { return hasSet || setStatements.Count > 0; }
  98.             set {
  99.                 hasSet = value;
  100.                 if (!value) {
  101.                     setStatements.Clear();
  102.                 }
  103.             }
  104.         }
  105.        
  106.         /// <devdoc>
  107.         /// <para>
  108.         /// Gets or sets the collection of get statements for the
  109.         /// property.
  110.         /// </para>
  111.         /// </devdoc>
  112.         public CodeStatementCollection GetStatements {
  113.             get { return getStatements; }
  114.         }
  115.        
  116.         /// <devdoc>
  117.         /// <para>
  118.         /// Gets or sets the collection of get statements for the property.
  119.         /// </para>
  120.         /// </devdoc>
  121.         public CodeStatementCollection SetStatements {
  122.             get { return setStatements; }
  123.         }
  124.        
  125.         /// <devdoc>
  126.         /// <para>
  127.         /// Gets or sets the collection of declaration expressions
  128.         /// for
  129.         /// the property.
  130.         /// </para>
  131.         /// </devdoc>
  132.         public CodeParameterDeclarationExpressionCollection Parameters {
  133.             get { return parameters; }
  134.         }
  135.     }
  136. }

Developer Fusion