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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="ExtenderProvidedPropertyAttribute.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.    
  20.     using System;
  21.     using System.Diagnostics;
  22.     using System.Security.Permissions;
  23.    
  24.     /// <internalonly/>
  25.     /// <devdoc>
  26.     /// <para>
  27.     /// ExtenderProvidedPropertyAttribute is an attribute that marks that a property
  28.     /// was actually offered up by and extender provider.
  29.     /// </para>
  30.     /// </devdoc>
  31.     [AttributeUsage(AttributeTargets.All)]
  32.     public sealed class ExtenderProvidedPropertyAttribute : Attribute
  33.     {
  34.        
  35.         private PropertyDescriptor extenderProperty;
  36.         private IExtenderProvider provider;
  37.         private Type receiverType;
  38.        
  39.         /// <devdoc>
  40.         /// Creates a new ExtenderProvidedPropertyAttribute.
  41.         /// </devdoc>
  42.         static internal ExtenderProvidedPropertyAttribute Create(PropertyDescriptor extenderProperty, Type receiverType, IExtenderProvider provider)
  43.         {
  44.             ExtenderProvidedPropertyAttribute e = new ExtenderProvidedPropertyAttribute();
  45.             e.extenderProperty = extenderProperty;
  46.             e.receiverType = receiverType;
  47.             e.provider = provider;
  48.             return e;
  49.         }
  50.        
  51.         /// <devdoc>
  52.         /// Creates an empty ExtenderProvidedPropertyAttribute.
  53.         /// </devdoc>
  54.         public ExtenderProvidedPropertyAttribute()
  55.         {
  56.         }
  57.        
  58.         /// <devdoc>
  59.         /// PropertyDescriptor of the property that is being provided.
  60.         /// </devdoc>
  61.         public PropertyDescriptor ExtenderProperty {
  62.             get { return extenderProperty; }
  63.         }
  64.        
  65.         /// <devdoc>
  66.         /// Extender provider that is providing the property.
  67.         /// </devdoc>
  68.         public IExtenderProvider Provider {
  69.             get { return provider; }
  70.         }
  71.        
  72.         /// <devdoc>
  73.         /// The type of object that can receive these properties.
  74.         /// </devdoc>
  75.         public Type ReceiverType {
  76.             get { return receiverType; }
  77.         }
  78.        
  79.         public override bool Equals(object obj)
  80.         {
  81.             if (obj == this) {
  82.                 return true;
  83.             }
  84.            
  85.             ExtenderProvidedPropertyAttribute other = obj as ExtenderProvidedPropertyAttribute;
  86.            
  87.             return (other != null) && other.extenderProperty.Equals(extenderProperty) && other.provider.Equals(provider) && other.receiverType.Equals(receiverType);
  88.         }
  89.        
  90.         public override int GetHashCode()
  91.         {
  92.             return base.GetHashCode();
  93.         }
  94.        
  95.         /// <internalonly/>
  96.         /// <devdoc>
  97.         /// </devdoc>
  98.         public override bool IsDefaultAttribute()
  99.         {
  100.             return receiverType == null;
  101.         }
  102.     }
  103. }

Developer Fusion