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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="ImmutableObjectAttribute.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.     using System;
  18.     using System.Diagnostics;
  19.     using System.Security.Permissions;
  20.    
  21.     /// <devdoc>
  22.     /// Specifies that a object has no sub properties that are editable.
  23.     /// </devdoc>
  24.     [AttributeUsage(AttributeTargets.All)]
  25.     public sealed class ImmutableObjectAttribute : Attribute
  26.     {
  27.        
  28.         /// <devdoc>
  29.         /// Specifies that a object has no sub properties that are editable.
  30.         ///
  31.         /// This is usually used in the properties window to determine if an expandable object
  32.         /// should be rendered as read-only.
  33.         /// </devdoc>
  34.         public static readonly ImmutableObjectAttribute Yes = new ImmutableObjectAttribute(true);
  35.        
  36.         /// <devdoc>
  37.         /// Specifies that a object has at least one editable sub-property.
  38.         ///
  39.         /// This is usually used in the properties window to determine if an expandable object
  40.         /// should be rendered as read-only.
  41.         /// </devdoc>
  42.         public static readonly ImmutableObjectAttribute No = new ImmutableObjectAttribute(false);
  43.        
  44.        
  45.         /// <devdoc>
  46.         /// Defaults to ImmutableObjectAttribute.No
  47.         /// </devdoc>
  48.         public static readonly ImmutableObjectAttribute Default = No;
  49.        
  50.         private bool immutable = true;
  51.        
  52.         /// <devdoc>
  53.         /// Constructs an ImmutableObjectAttribute object.
  54.         ///
  55.         /// </devdoc>
  56.         public ImmutableObjectAttribute(bool immutable)
  57.         {
  58.             this.immutable = immutable;
  59.         }
  60.        
  61.         /// <devdoc>
  62.         /// <para>[To be supplied.]</para>
  63.         /// </devdoc>
  64.         public bool Immutable {
  65.             get { return immutable; }
  66.         }
  67.        
  68.         /// <internalonly/>
  69.         /// <devdoc>
  70.         /// </devdoc>
  71.         public override bool Equals(object obj)
  72.         {
  73.             if (obj == this) {
  74.                 return true;
  75.             }
  76.            
  77.             ImmutableObjectAttribute other = obj as ImmutableObjectAttribute;
  78.             return other != null && other.Immutable == this.immutable;
  79.         }
  80.        
  81.         /// <devdoc>
  82.         /// <para>
  83.         /// Returns the hashcode for this object.
  84.         /// </para>
  85.         /// </devdoc>
  86.         public override int GetHashCode()
  87.         {
  88.             return base.GetHashCode();
  89.         }
  90.        
  91.         /// <internalonly/>
  92.         /// <devdoc>
  93.         /// </devdoc>
  94.         public override bool IsDefaultAttribute()
  95.         {
  96.             return (this.Equals(Default));
  97.         }
  98.        
  99.     }
  100. }

Developer Fusion