//------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //------------------------------------------------------------------------------ /* */ namespace System.ComponentModel { using System; using System.ComponentModel; using System.Diagnostics; using System.Security.Permissions; /// /// Specifies whether a property is appropriate to bind data /// to. /// [AttributeUsage(AttributeTargets.All)] public sealed class BindableAttribute : Attribute { /// /// /// Specifies that a property is appropriate to bind data to. This /// field is read-only. /// /// public static readonly BindableAttribute Yes = new BindableAttribute(true); /// /// /// Specifies that a property is not appropriate to bind /// data to. This field is read-only. /// /// public static readonly BindableAttribute No = new BindableAttribute(false); /// /// /// Specifies the default value for the , /// which is . This field is /// read-only. /// /// public static readonly BindableAttribute Default = No; private bool bindable = false; private bool isDefault = false; private BindingDirection direction; /// /// /// Initializes a new instance of the class. /// /// public BindableAttribute(bool bindable) : this(bindable, BindingDirection.OneWay) { } /// /// /// Initializes a new instance of the class. /// /// public BindableAttribute(bool bindable, BindingDirection direction) { this.bindable = bindable; this.direction = direction; } /// /// /// Initializes a new instance of the class. /// /// public BindableAttribute(BindableSupport flags) : this(flags, BindingDirection.OneWay) { } /// /// /// Initializes a new instance of the class. /// /// public BindableAttribute(BindableSupport flags, BindingDirection direction) { this.bindable = (flags != BindableSupport.No); this.isDefault = (flags == BindableSupport.Default); this.direction = direction; } /// /// /// Gets a value indicating /// whether a property is appropriate to bind data to. /// /// public bool Bindable { get { return bindable; } } /// /// /// Gets a value indicating /// the direction(s) this property be bound to data. /// /// public BindingDirection Direction { get { return direction; } } /// /// /// public override bool Equals(object obj) { if (obj == this) { return true; } if (obj != null && obj is BindableAttribute) { return (((BindableAttribute)obj).Bindable == bindable); } return false; } /// /// [To be supplied.] /// public override int GetHashCode() { return bindable.GetHashCode(); } #if !SILVERLIGHT /// /// /// public override bool IsDefaultAttribute() { return (this.Equals(Default) || isDefault); } #endif } }