The Labs \ Source Viewer \ SSCLI \ System.ComponentModel \ WarningException

  1. //------------------------------------------------------------------------------
  2. // <copyright file="Warning.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. /*
  16. */
  17. namespace System.ComponentModel
  18. {
  19.     using Microsoft.Win32;
  20.     using System;
  21.     using System.Diagnostics;
  22.     using System.Runtime.InteropServices;
  23.     using System.Runtime.Serialization;
  24.     using System.Security.Permissions;
  25.    
  26.     /// <devdoc>
  27.     /// <para>Specifies an exception that is handled as a warning instead of an error.</para>
  28.     /// </devdoc>
  29.     [HostProtection(SharedState = true)]
  30.     [Serializable()]
  31.     public class WarningException : SystemException
  32.     {
  33.         private readonly string helpUrl;
  34.         private readonly string helpTopic;
  35.        
  36.         /// <devdoc>
  37.         /// <para>Initializes a new instance of the <see cref='System.ComponentModel.Win32Exception'/> class with the last Win32 error
  38.         /// that occured.</para>
  39.         /// </devdoc>
  40.         public WarningException() : this(null, null, null)
  41.         {
  42.         }
  43.        
  44.         /// <devdoc>
  45.         /// <para>Initializes a new instance of the <see cref='System.ComponentModel.WarningException'/> class with
  46.         /// the specified message and no Help file.</para>
  47.         /// </devdoc>
  48.         public WarningException(string message) : this(message, null, null)
  49.         {
  50.         }
  51.        
  52.         /// <devdoc>
  53.         /// <para>Initializes a new instance of the <see cref='System.ComponentModel.WarningException'/> class with
  54.         /// the specified message, and with access to the specified Help file.</para>
  55.         /// </devdoc>
  56.         public WarningException(string message, string helpUrl) : this(message, helpUrl, null)
  57.         {
  58.         }
  59.        
  60.         /// <devdoc>
  61.         /// Initializes a new instance of the Exception class with a specified error message and a
  62.         /// reference to the inner exception that is the cause of this exception.
  63.         /// FxCop CA1032: Multiple constructors are required to correctly implement a custom exception.
  64.         /// </devdoc>
  65.         public WarningException(string message, Exception innerException) : base(message, innerException)
  66.         {
  67.         }
  68.        
  69.         /// <devdoc>
  70.         /// <para>Initializes a new instance of the <see cref='System.ComponentModel.WarningException'/> class with the
  71.         /// specified message, and with access to the specified Help file and topic.</para>
  72.         /// </devdoc>
  73.         public WarningException(string message, string helpUrl, string helpTopic) : base(message)
  74.         {
  75.             this.helpUrl = helpUrl;
  76.             this.helpTopic = helpTopic;
  77.         }
  78.        
  79.         /// <devdoc>
  80.         /// Need this constructor since Exception implements ISerializable.
  81.         /// </devdoc>
  82.         protected WarningException(SerializationInfo info, StreamingContext context) : base(info, context)
  83.         {
  84.             helpUrl = (string)info.GetValue("helpUrl", typeof(string));
  85.             helpTopic = (string)info.GetValue("helpTopic", typeof(string));
  86.         }
  87.        
  88.         /// <devdoc>
  89.         /// <para> Specifies the Help file associated with the
  90.         /// warning. This field is read-only.</para>
  91.         /// </devdoc>
  92.         public string HelpUrl {
  93.             get { return helpUrl; }
  94.         }
  95.        
  96.         /// <devdoc>
  97.         /// <para> Specifies the
  98.         /// Help topic associated with the warning. This field is read-only. </para>
  99.         /// </devdoc>
  100.         public string HelpTopic {
  101.             get { return helpTopic; }
  102.         }
  103.        
  104.         /// <devdoc>
  105.         /// Need this since Exception implements ISerializable and we have fields to save out.
  106.         /// </devdoc>
  107.         [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
  108.         public override void GetObjectData(SerializationInfo info, StreamingContext context)
  109.         {
  110.             if (info == null) {
  111.                 throw new ArgumentNullException("info");
  112.             }
  113.            
  114.             info.AddValue("helpUrl", helpUrl);
  115.             info.AddValue("helpTopic", helpTopic);
  116.            
  117.             base.GetObjectData(info, context);
  118.         }
  119.     }
  120. }

Developer Fusion