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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="MergablePropertyAttribute.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 that
  26.     /// this property can be combined with properties belonging to
  27.     /// other objects in a properties window.</para>
  28.     /// </devdoc>
  29.     [AttributeUsage(AttributeTargets.All)]
  30.     public sealed class MergablePropertyAttribute : Attribute
  31.     {
  32.        
  33.         /// <devdoc>
  34.         /// <para>
  35.         /// Specifies that a property can be combined with properties belonging to other
  36.         /// objects in a properties window. This <see langword='static '/>field is read-only.
  37.         /// </para>
  38.         /// </devdoc>
  39.         public static readonly MergablePropertyAttribute Yes = new MergablePropertyAttribute(true);
  40.        
  41.         /// <devdoc>
  42.         /// <para>
  43.         /// Specifies that a property cannot be combined with properties belonging to
  44.         /// other objects in a properties window. This <see langword='static '/>field is
  45.         /// read-only.
  46.         /// </para>
  47.         /// </devdoc>
  48.         public static readonly MergablePropertyAttribute No = new MergablePropertyAttribute(false);
  49.        
  50.         /// <devdoc>
  51.         /// <para>
  52.         /// Specifies the default value, which is <see cref='System.ComponentModel.MergablePropertyAttribute.Yes'/>, that is a property can be combined with
  53.         /// properties belonging to other objects in a properties window. This <see langword='static '/>field is read-only.
  54.         /// </para>
  55.         /// </devdoc>
  56.         public static readonly MergablePropertyAttribute Default = Yes;
  57.        
  58.         private bool allowMerge;
  59.        
  60.         /// <devdoc>
  61.         /// <para>
  62.         /// Initializes a new instance of the <see cref='System.ComponentModel.MergablePropertyAttribute'/>
  63.         /// class.
  64.         /// </para>
  65.         /// </devdoc>
  66.         public MergablePropertyAttribute(bool allowMerge)
  67.         {
  68.             this.allowMerge = allowMerge;
  69.         }
  70.        
  71.         /// <devdoc>
  72.         /// <para>
  73.         /// Gets a value indicating whether this
  74.         /// property can be combined with properties belonging to other objects in a
  75.         /// properties window.
  76.         /// </para>
  77.         /// </devdoc>
  78.         public bool AllowMerge {
  79.             get { return allowMerge; }
  80.         }
  81.        
  82.         /// <internalonly/>
  83.         /// <devdoc>
  84.         /// </devdoc>
  85.         public override bool Equals(object obj)
  86.         {
  87.             if (obj == this) {
  88.                 return true;
  89.             }
  90.            
  91.             MergablePropertyAttribute other = obj as MergablePropertyAttribute;
  92.             return other != null && other.AllowMerge == this.allowMerge;
  93.         }
  94.        
  95.         /// <devdoc>
  96.         /// <para>
  97.         /// Returns the hashcode for this object.
  98.         /// </para>
  99.         /// </devdoc>
  100.         public override int GetHashCode()
  101.         {
  102.             return base.GetHashCode();
  103.         }
  104.        
  105.         /// <devdoc>
  106.         /// </devdoc>
  107.         /// <internalonly/>
  108.         public override bool IsDefaultAttribute()
  109.         {
  110.             return (this.Equals(Default));
  111.         }
  112.     }
  113. }

Developer Fusion