1 //------------------------------------------------------------------------------ 2 // <copyright file="SettingsBindableAttribute.cs" company="Microsoft"> 3 // Copyright (c) Microsoft Corporation. All rights reserved. 4 // </copyright> 5 //------------------------------------------------------------------------------ 6 7 /* 8 */ 9 namespace System.ComponentModel { 10 using System; 11 using System.Diagnostics; 12 using System.Security.Permissions; 13 14 /// <devdoc> 15 /// Use this attribute to specify typical properties on components that can be bound 16 /// to application settings. 17 /// </devdoc> 18 [AttributeUsage(AttributeTargets.Property)] 19 public sealed class SettingsBindableAttribute : Attribute { 20 /// <devdoc> 21 /// Specifies that a property is appropriate to bind settings to. 22 /// </devdoc> 23 public static readonly SettingsBindableAttribute Yes = new SettingsBindableAttribute(true); 24 25 /// <devdoc> 26 /// Specifies that a property is not appropriate to bind settings to. 27 /// </devdoc> 28 public static readonly SettingsBindableAttribute No = new SettingsBindableAttribute(false); 29 30 private bool _bindable = false; 31 SettingsBindableAttribute(bool bindable)32 public SettingsBindableAttribute(bool bindable) { 33 _bindable = bindable; 34 } 35 36 /// <devdoc> 37 /// Gets a value indicating whether a property is appropriate to bind settings to. 38 /// </devdoc> 39 public bool Bindable { 40 get { 41 return _bindable; 42 } 43 } 44 Equals(object obj)45 public override bool Equals(object obj) { 46 if (obj == this) { 47 return true; 48 } 49 50 if (obj != null && obj is SettingsBindableAttribute) { 51 return (((SettingsBindableAttribute)obj).Bindable == _bindable); 52 } 53 54 return false; 55 } 56 GetHashCode()57 public override int GetHashCode() { 58 return _bindable.GetHashCode(); 59 } 60 } 61 } 62