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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="CodeCatchClause.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>Represents a catch exception block.</para>
  26.     /// </devdoc>
  27.     [ClassInterface(ClassInterfaceType.AutoDispatch), ComVisible(true), Serializable()]
  28.     public class CodeCatchClause
  29.     {
  30.         private CodeStatementCollection statements;
  31.         private CodeTypeReference catchExceptionType;
  32.         private string localName;
  33.        
  34.         /// <devdoc>
  35.         /// <para>
  36.         /// Initializes an instance of <see cref='System.CodeDom.CodeCatchClause'/>.
  37.         /// </para>
  38.         /// </devdoc>
  39.         public CodeCatchClause()
  40.         {
  41.         }
  42.        
  43.         /// <devdoc>
  44.         /// <para>[To be supplied.]</para>
  45.         /// </devdoc>
  46.         public CodeCatchClause(string localName)
  47.         {
  48.             this.localName = localName;
  49.         }
  50.        
  51.         /// <devdoc>
  52.         /// <para>[To be supplied.]</para>
  53.         /// </devdoc>
  54.         public CodeCatchClause(string localName, CodeTypeReference catchExceptionType)
  55.         {
  56.             this.localName = localName;
  57.             this.catchExceptionType = catchExceptionType;
  58.         }
  59.        
  60.         /// <devdoc>
  61.         /// <para>[To be supplied.]</para>
  62.         /// </devdoc>
  63.         public CodeCatchClause(string localName, CodeTypeReference catchExceptionType, params CodeStatement[] statements)
  64.         {
  65.             this.localName = localName;
  66.             this.catchExceptionType = catchExceptionType;
  67.             Statements.AddRange(statements);
  68.         }
  69.        
  70.         /// <devdoc>
  71.         /// <para>[To be supplied.]</para>
  72.         /// </devdoc>
  73.         public string LocalName {
  74.             get { return (localName == null) ? string.Empty : localName; }
  75.             set { localName = value; }
  76.         }
  77.        
  78.         /// <devdoc>
  79.         /// <para>[To be supplied.]</para>
  80.         /// </devdoc>
  81.         public CodeTypeReference CatchExceptionType {
  82.             get {
  83.                 if (catchExceptionType == null) {
  84.                     catchExceptionType = new CodeTypeReference(typeof(System.Exception));
  85.                 }
  86.                 return catchExceptionType;
  87.             }
  88.             set { catchExceptionType = value; }
  89.         }
  90.        
  91.         /// <devdoc>
  92.         /// <para>
  93.         /// Gets or sets the statements within the clause.
  94.         /// </para>
  95.         /// </devdoc>
  96.         public CodeStatementCollection Statements {
  97.             get {
  98.                 if (statements == null) {
  99.                     statements = new CodeStatementCollection();
  100.                 }
  101.                 return statements;
  102.             }
  103.         }
  104.     }
  105. }

Developer Fusion