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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="SettingsBindableAttribute.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.     /// Use this attribute to specify typical properties on components that can be bound
  25.     /// to application settings.
  26.     /// </devdoc>
  27.     [AttributeUsage(AttributeTargets.Property)]
  28.     public sealed class SettingsBindableAttribute : Attribute
  29.     {
  30.         /// <devdoc>
  31.         /// Specifies that a property is appropriate to bind settings to.
  32.         /// </devdoc>
  33.         public static readonly SettingsBindableAttribute Yes = new SettingsBindableAttribute(true);
  34.        
  35.         /// <devdoc>
  36.         /// Specifies that a property is not appropriate to bind settings to.
  37.         /// </devdoc>
  38.         public static readonly SettingsBindableAttribute No = new SettingsBindableAttribute(false);
  39.        
  40.         private bool _bindable = false;
  41.        
  42.         public SettingsBindableAttribute(bool bindable)
  43.         {
  44.             _bindable = bindable;
  45.         }
  46.        
  47.         /// <devdoc>
  48.         /// Gets a value indicating whether a property is appropriate to bind settings to.
  49.         /// </devdoc>
  50.         public bool Bindable {
  51.             get { return _bindable; }
  52.         }
  53.        
  54.         public override bool Equals(object obj)
  55.         {
  56.             if (obj == this) {
  57.                 return true;
  58.             }
  59.            
  60.             if (obj != null && obj is SettingsBindableAttribute) {
  61.                 return (((SettingsBindableAttribute)obj).Bindable == _bindable);
  62.             }
  63.            
  64.             return false;
  65.         }
  66.        
  67.         public override int GetHashCode()
  68.         {
  69.             return _bindable.GetHashCode();
  70.         }
  71.     }
  72. }

Developer Fusion