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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="RecommendedAsConfigurableAttribute.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.     /// <devdoc>
  25.     /// <para>Specifies that the property can be
  26.     /// used as an application setting.</para>
  27.     /// </devdoc>
  28.     [AttributeUsage(AttributeTargets.Property)]
  29.     [Obsolete("Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")]
  30.     public class RecommendedAsConfigurableAttribute : Attribute
  31.     {
  32.         private bool recommendedAsConfigurable = false;
  33.        
  34.         /// <devdoc>
  35.         /// <para>
  36.         /// Initializes a new instance of
  37.         /// the <see cref='System.ComponentModel.RecommendedAsConfigurableAttribute'/> class.
  38.         /// </para>
  39.         /// </devdoc>
  40.         public RecommendedAsConfigurableAttribute(bool recommendedAsConfigurable)
  41.         {
  42.             this.recommendedAsConfigurable = recommendedAsConfigurable;
  43.         }
  44.        
  45.         /// <devdoc>
  46.         /// <para>Gets a value indicating whether the property this
  47.         /// attribute is bound to can be used as an application setting.</para>
  48.         /// </devdoc>
  49.         public bool RecommendedAsConfigurable {
  50.             get { return recommendedAsConfigurable; }
  51.         }
  52.        
  53.         /// <devdoc>
  54.         /// <para>
  55.         /// Specifies that a property cannot be used as an application setting. This
  56.         /// <see langword='static '/>field is read-only.
  57.         /// </para>
  58.         /// </devdoc>
  59.         public static readonly RecommendedAsConfigurableAttribute No = new RecommendedAsConfigurableAttribute(false);
  60.        
  61.         /// <devdoc>
  62.         /// <para>
  63.         /// Specifies
  64.         /// that a property can be used as an application setting. This <see langword='static '/>field is read-only.
  65.         /// </para>
  66.         /// </devdoc>
  67.         public static readonly RecommendedAsConfigurableAttribute Yes = new RecommendedAsConfigurableAttribute(true);
  68.        
  69.         /// <devdoc>
  70.         /// <para>
  71.         /// Specifies the default value for the <see cref='System.ComponentModel.RecommendedAsConfigurableAttribute'/>, which is <see cref='System.ComponentModel.RecommendedAsConfigurableAttribute.No'/>. This <see langword='static '/>field is
  72.         /// read-only.
  73.         /// </para>
  74.         /// </devdoc>
  75.         public static readonly RecommendedAsConfigurableAttribute Default = No;
  76.        
  77.         /// <internalonly/>
  78.         /// <devdoc>
  79.         /// </devdoc>
  80.         public override bool Equals(object obj)
  81.         {
  82.             if (obj == this) {
  83.                 return true;
  84.             }
  85.            
  86.             RecommendedAsConfigurableAttribute other = obj as RecommendedAsConfigurableAttribute;
  87.            
  88.             return other != null && other.RecommendedAsConfigurable == recommendedAsConfigurable;
  89.            
  90.            
  91.         }
  92.        
  93.         /// <devdoc>
  94.         /// <para>
  95.         /// Returns the hashcode for this object.
  96.         /// </para>
  97.         /// </devdoc>
  98.         public override int GetHashCode()
  99.         {
  100.             return base.GetHashCode();
  101.         }
  102.        
  103.         /// <internalonly/>
  104.         /// <devdoc>
  105.         /// </devdoc>
  106.         public override bool IsDefaultAttribute()
  107.         {
  108.             return !recommendedAsConfigurable;
  109.         }
  110.     }
  111. }

Developer Fusion