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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="DefaultPropertyAttribute.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.    
  23.     /// <devdoc>
  24.     /// <para>Specifies the default property for a component.</para>
  25.     /// </devdoc>
  26.     [AttributeUsage(AttributeTargets.Class)]
  27.     public sealed class DefaultPropertyAttribute : Attribute
  28.     {
  29.         /// <devdoc>
  30.         /// This is the default event name.
  31.         /// </devdoc>
  32.         private readonly string name;
  33.        
  34.         /// <devdoc>
  35.         /// <para>
  36.         /// Initializes a new instance of
  37.         /// the <see cref='System.ComponentModel.DefaultPropertyAttribute'/> class.
  38.         /// </para>
  39.         /// </devdoc>
  40.         public DefaultPropertyAttribute(string name)
  41.         {
  42.             this.name = name;
  43.         }
  44.        
  45.         /// <devdoc>
  46.         /// <para>
  47.         /// Gets the name of the default property for the component this attribute is
  48.         /// bound to.
  49.         /// </para>
  50.         /// </devdoc>
  51.         public string Name {
  52.             get { return name; }
  53.         }
  54.        
  55.         /// <devdoc>
  56.         /// <para>
  57.         /// Specifies the default value for the <see cref='System.ComponentModel.DefaultPropertyAttribute'/>, which is <see langword='null'/>. This
  58.         /// <see langword='static '/>field is read-only.
  59.         /// </para>
  60.         /// </devdoc>
  61.         public static readonly DefaultPropertyAttribute Default = new DefaultPropertyAttribute(null);
  62.        
  63.         public override bool Equals(object obj)
  64.         {
  65.             DefaultPropertyAttribute other = obj as DefaultPropertyAttribute;
  66.             return (other != null) && other.Name == name;
  67.         }
  68.        
  69.         public override int GetHashCode()
  70.         {
  71.             return base.GetHashCode();
  72.         }
  73.     }
  74. }

Developer Fusion