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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="ParenthesizePropertyNameAttribute.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.ComponentModel
  16. {
  17.    
  18.     using System;
  19.     using System.Security.Permissions;
  20.    
  21.     /// <devdoc>
  22.     /// <para>Provides a value indicating whether the name of the associated property is parenthesized in the
  23.     /// properties window.</para>
  24.     /// </devdoc>
  25.     [AttributeUsage(AttributeTargets.All)]
  26.     public sealed class ParenthesizePropertyNameAttribute : Attribute
  27.     {
  28.         /// <devdoc>
  29.         /// <para>
  30.         /// Sets the System.ComponentModel.Design.ParenthesizePropertyName
  31.         /// attribute by default to
  32.         /// <see langword='false'/>.
  33.         /// </para>
  34.         /// </devdoc>
  35.         public static readonly ParenthesizePropertyNameAttribute Default = new ParenthesizePropertyNameAttribute();
  36.        
  37.         private bool needParenthesis;
  38.        
  39.         /// <devdoc>
  40.         /// <para>[To be supplied.]</para>
  41.         /// </devdoc>
  42.         public ParenthesizePropertyNameAttribute() : this(false)
  43.         {
  44.         }
  45.        
  46.         /// <devdoc>
  47.         /// <para>Initializes a new instance of the System.ComponentModel.Design.ParenthesizePropertyNameAttribute
  48.         /// class, using the specified value to indicate whether the attribute is
  49.         /// marked for display with parentheses.</para>
  50.         /// </devdoc>
  51.         public ParenthesizePropertyNameAttribute(bool needParenthesis)
  52.         {
  53.             this.needParenthesis = needParenthesis;
  54.         }
  55.        
  56.         /// <devdoc>
  57.         /// <para>
  58.         /// Gets a value indicating
  59.         /// whether the
  60.         /// attribute is placed in parentheses when listed in
  61.         /// the properties window.
  62.         /// </para>
  63.         /// </devdoc>
  64.         public bool NeedParenthesis {
  65.             get { return needParenthesis; }
  66.         }
  67.        
  68.         /// <devdoc>
  69.         /// <para>Compares the specified object
  70.         /// to this object and tests for equality.</para>
  71.         /// </devdoc>
  72.         public override bool Equals(object o)
  73.         {
  74.             if (o is ParenthesizePropertyNameAttribute) {
  75.                 return ((ParenthesizePropertyNameAttribute)o).NeedParenthesis == needParenthesis;
  76.             }
  77.             return false;
  78.         }
  79.        
  80.         /// <devdoc>
  81.         /// <para>
  82.         /// Returns the hashcode for this object.
  83.         /// </para>
  84.         /// </devdoc>
  85.         public override int GetHashCode()
  86.         {
  87.             return base.GetHashCode();
  88.         }
  89.        
  90.         /// <devdoc>
  91.         /// <para>Gets a value indicating whether this attribute is set to <see langword='true'/> by default.</para>
  92.         /// </devdoc>
  93.         public override bool IsDefaultAttribute()
  94.         {
  95.             return this.Equals(Default);
  96.         }
  97.     }
  98. }

Developer Fusion