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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="BrowsableAttribute.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 System;
  20.     using System.ComponentModel;
  21.     using System.Diagnostics;
  22.     using System.Security.Permissions;
  23.    
  24.     /// <devdoc>
  25.     /// <para>Specifies whether a property or event should be displayed in
  26.     /// a property browsing window.</para>
  27.     /// </devdoc>
  28.     [AttributeUsage(AttributeTargets.All)]
  29.     public sealed class BrowsableAttribute : Attribute
  30.     {
  31.         /// <devdoc>
  32.         /// <para>
  33.         /// Specifies that a property or event can be modified at
  34.         /// design time. This <see langword='static '/>
  35.         /// field is read-only.
  36.         /// </para>
  37.         /// </devdoc>
  38.         public static readonly BrowsableAttribute Yes = new BrowsableAttribute(true);
  39.        
  40.         /// <devdoc>
  41.         /// <para>
  42.         /// Specifies that a property or event cannot be modified at
  43.         /// design time. This <see langword='static '/>field is read-only.
  44.         /// </para>
  45.         /// </devdoc>
  46.         public static readonly BrowsableAttribute No = new BrowsableAttribute(false);
  47.        
  48.         /// <devdoc>
  49.         /// <para>Specifies the default value for the <see cref='System.ComponentModel.BrowsableAttribute'/>,
  50.         /// which is <see cref='System.ComponentModel.BrowsableAttribute.Yes'/>. This <see langword='static '/>field is read-only.</para>
  51.         /// </devdoc>
  52.         public static readonly BrowsableAttribute Default = Yes;
  53.        
  54.         private bool browsable = true;
  55.        
  56.         /// <devdoc>
  57.         /// <para>Initializes a new instance of the <see cref='System.ComponentModel.BrowsableAttribute'/> class.</para>
  58.         /// </devdoc>
  59.         public BrowsableAttribute(bool browsable)
  60.         {
  61.             this.browsable = browsable;
  62.         }
  63.        
  64.         /// <devdoc>
  65.         /// <para>
  66.         /// Gets a value indicating whether an object is browsable.
  67.         /// </para>
  68.         /// </devdoc>
  69.         public bool Browsable {
  70.             get { return browsable; }
  71.         }
  72.        
  73.         /// <internalonly/>
  74.         /// <devdoc>
  75.         /// </devdoc>
  76.         public override bool Equals(object obj)
  77.         {
  78.             if (obj == this) {
  79.                 return true;
  80.             }
  81.            
  82.             BrowsableAttribute other = obj as BrowsableAttribute;
  83.            
  84.             return (other != null) && other.Browsable == browsable;
  85.         }
  86.        
  87.         /// <devdoc>
  88.         /// <para>[To be supplied.]</para>
  89.         /// </devdoc>
  90.         public override int GetHashCode()
  91.         {
  92.             return browsable.GetHashCode();
  93.         }
  94.        
  95.         /// <internalonly/>
  96.         /// <devdoc>
  97.         /// </devdoc>
  98.         public override bool IsDefaultAttribute()
  99.         {
  100.             return (this.Equals(Default));
  101.         }
  102.     }
  103. }

Developer Fusion