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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="DesignerSerializationVisibilityAttribute.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.Diagnostics;
  21.     using System.Security.Permissions;
  22.     /// <devdoc>
  23.     /// <para>
  24.     /// Specifies the visibility of this property or method as seen
  25.     /// by the designer serializer.
  26.     /// </para>
  27.     /// </devdoc>
  28.     [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Event)]
  29.     public sealed class DesignerSerializationVisibilityAttribute : Attribute
  30.     {
  31.         /// <devdoc>
  32.         /// <para>
  33.         /// Specifies that a visual designer should serialize the contents of this property,
  34.         /// rather than the property itself.
  35.         /// This <see langword='static '/>field is read-only.
  36.         /// </para>
  37.         /// </devdoc>
  38.         public static readonly DesignerSerializationVisibilityAttribute Content = new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content);
  39.        
  40.         /// <devdoc>
  41.         /// <para>
  42.         /// Specifies that a
  43.         /// visual designer will not serialize the value of this property.
  44.         /// This <see langword='static '/>field is read-only.
  45.         /// </para>
  46.         /// </devdoc>
  47.         public static readonly DesignerSerializationVisibilityAttribute Hidden = new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden);
  48.        
  49.         /// <devdoc>
  50.         /// <para>
  51.         /// Specifies that a
  52.         /// visual designer may use default rules when serializing the value of a property.
  53.         /// This <see langword='static '/>field is read-only.
  54.         /// </para>
  55.         /// </devdoc>
  56.         public static readonly DesignerSerializationVisibilityAttribute Visible = new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible);
  57.        
  58.         /// <devdoc>
  59.         /// <para>
  60.         /// Specifies the default value, which is <see cref='System.ComponentModel.DesignerSerializationVisibilityAttribute.Visible'/>, that is, a visual designer
  61.         /// uses default rules to generate the value of a property. This
  62.         /// <see langword='static '/>field is read-only.
  63.         /// </para>
  64.         /// </devdoc>
  65.         public static readonly DesignerSerializationVisibilityAttribute Default = Visible;
  66.        
  67.         private DesignerSerializationVisibility visibility;
  68.        
  69.         /// <devdoc>
  70.         /// <para>
  71.         /// Initializes a new instance of the System.ComponentModel.PersistContentsAttribute class.
  72.         /// </para>
  73.         /// </devdoc>
  74.         public DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility visibility)
  75.         {
  76.             this.visibility = visibility;
  77.         }
  78.        
  79.         /// <devdoc>
  80.         /// <para>
  81.         /// Gets a value indicating whether a
  82.         /// visual designer must generate special code to persist the value of a property.
  83.         /// </para>
  84.         /// </devdoc>
  85.         public DesignerSerializationVisibility Visibility {
  86.             get { return visibility; }
  87.         }
  88.        
  89.         /// <internalonly/>
  90.         /// <devdoc>
  91.         /// </devdoc>
  92.         public override bool Equals(object obj)
  93.         {
  94.            
  95.             if (obj == this) {
  96.                 return true;
  97.             }
  98.            
  99.             DesignerSerializationVisibilityAttribute other = obj as DesignerSerializationVisibilityAttribute;
  100.             return other != null && other.Visibility == visibility;
  101.         }
  102.        
  103.         /// <devdoc>
  104.         /// <para>
  105.         /// Returns the hashcode for this object.
  106.         /// </para>
  107.         /// </devdoc>
  108.         public override int GetHashCode()
  109.         {
  110.             return base.GetHashCode();
  111.         }
  112.        
  113.         /// <devdoc>
  114.         /// </devdoc>
  115.         /// <internalonly/>
  116.         public override bool IsDefaultAttribute()
  117.         {
  118.             return (this.Equals(Default));
  119.         }
  120.     }
  121. }

Developer Fusion