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

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

Developer Fusion