The Labs \ Source Viewer \ SSCLI \ System.ComponentModel.Design \ HelpKeywordAttribute

  1. //------------------------------------------------------------------------------
  2. // <copyright file="HelpKeywordAttribute.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.Design
  18. {
  19.     using System;
  20.     using System.Security.Permissions;
  21.    
  22.     [AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = false)]
  23.     [Serializable()]
  24.     public sealed class HelpKeywordAttribute : Attribute
  25.     {
  26.        
  27.         /// <devdoc>
  28.         /// Default value for HelpKeywordAttribute, which is null.
  29.         /// </devdoc>
  30.         public static readonly HelpKeywordAttribute Default = new HelpKeywordAttribute();
  31.        
  32.         private string contextKeyword;
  33.        
  34.         /// <devdoc>
  35.         /// Default constructor, which creates an attribute with a null HelpKeyword.
  36.         /// </devdoc>
  37.         public HelpKeywordAttribute()
  38.         {
  39.         }
  40.        
  41.         /// <devdoc>
  42.         /// Creates a HelpKeywordAttribute with the value being the given keyword string.
  43.         /// </devdoc>
  44.         public HelpKeywordAttribute(string keyword)
  45.         {
  46.             if (keyword == null) {
  47.                 throw new ArgumentNullException("keyword");
  48.             }
  49.             this.contextKeyword = keyword;
  50.         }
  51.        
  52.         /// <devdoc>
  53.         /// Creates a HelpKeywordAttribute with the value being the full name of the given type.
  54.         /// </devdoc>
  55.         public HelpKeywordAttribute(Type t)
  56.         {
  57.             if (t == null) {
  58.                 throw new ArgumentNullException("t");
  59.             }
  60.             this.contextKeyword = t.FullName;
  61.         }
  62.        
  63.         /// <devdoc>
  64.         /// Retrieves the HelpKeyword this attribute supplies.
  65.         /// </devdoc>
  66.         public string HelpKeyword {
  67.             get { return contextKeyword; }
  68.         }
  69.        
  70.        
  71.         /// <devdoc>
  72.         /// Two instances of a HelpKeywordAttribute are equal if they're HelpKeywords are equal.
  73.         /// </devdoc>
  74.         public override bool Equals(object obj)
  75.         {
  76.             if (obj == this) {
  77.                 return true;
  78.             }
  79.             if ((obj != null) && (obj is HelpKeywordAttribute)) {
  80.                 return ((HelpKeywordAttribute)obj).HelpKeyword == HelpKeyword;
  81.             }
  82.            
  83.             return false;
  84.         }
  85.        
  86.         /// <devdoc>
  87.         /// </devdoc>
  88.         public override int GetHashCode()
  89.         {
  90.             return base.GetHashCode();
  91.         }
  92.        
  93.         /// <devdoc>
  94.         /// Returns true if this Attribute's HelpKeyword is null.
  95.         /// </devdoc>
  96.         public override bool IsDefaultAttribute()
  97.         {
  98.             return this.Equals(Default);
  99.         }
  100.     }
  101. }

Developer Fusion