//------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //------------------------------------------------------------------------------ /* */ namespace System.ComponentModel { using System; using System.Diagnostics; using System.Security.Permissions; /// /// Specifies which methods are extender /// properties. /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public sealed class ProvidePropertyAttribute : Attribute { private readonly string propertyName; private readonly string receiverTypeName; /// /// Initializes a new instance of the class. /// public ProvidePropertyAttribute(string propertyName, Type receiverType) { this.propertyName = propertyName; this.receiverTypeName = receiverType.AssemblyQualifiedName; } /// /// Initializes a new instance of the class. /// public ProvidePropertyAttribute(string propertyName, string receiverTypeName) { this.propertyName = propertyName; this.receiverTypeName = receiverTypeName; } /// /// /// Gets the name of a property that this class provides. /// /// public string PropertyName { get { return propertyName; } } /// /// /// Gets the name of the data type this property can extend /// /// public string ReceiverTypeName { get { return receiverTypeName; } } /// /// ProvidePropertyAttribute overrides this to include the type name and the property name /// public override object TypeId { get { return GetType().FullName + propertyName; } } public override bool Equals(object obj) { if (obj == this) { return true; } ProvidePropertyAttribute other = obj as ProvidePropertyAttribute; return (other != null) && other.propertyName == propertyName && other.receiverTypeName == receiverTypeName; } public override int GetHashCode() { return propertyName.GetHashCode() ^ receiverTypeName.GetHashCode(); } } }