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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="LocalizableAttribute.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 whether a property should be localized.</para>
  26.     /// </devdoc>
  27.     [AttributeUsage(AttributeTargets.All)]
  28.     public sealed class LocalizableAttribute : Attribute
  29.     {
  30.         private bool isLocalizable = false;
  31.        
  32.         /// <devdoc>
  33.         /// <para>
  34.         /// Initializes a new instance of the <see cref='System.ComponentModel.LocalizableAttribute'/> class.
  35.         /// </para>
  36.         /// </devdoc>
  37.         public LocalizableAttribute(bool isLocalizable)
  38.         {
  39.             this.isLocalizable = isLocalizable;
  40.         }
  41.        
  42.         /// <devdoc>
  43.         /// <para>
  44.         /// Gets a value indicating whether
  45.         /// a property should be localized.
  46.         /// </para>
  47.         /// </devdoc>
  48.         public bool IsLocalizable {
  49.             get { return isLocalizable; }
  50.         }
  51.        
  52.         /// <devdoc>
  53.         /// <para>
  54.         /// Specifies that a property should be localized. This
  55.         /// <see langword='static '/>field is read-only.
  56.         /// </para>
  57.         /// </devdoc>
  58.         public static readonly LocalizableAttribute Yes = new LocalizableAttribute(true);
  59.        
  60.         /// <devdoc>
  61.         /// <para>
  62.         /// Specifies that a property should not be localized. This
  63.         /// <see langword='static '/>field is read-only.
  64.         /// </para>
  65.         /// </devdoc>
  66.         public static readonly LocalizableAttribute No = new LocalizableAttribute(false);
  67.        
  68.         /// <devdoc>
  69.         /// <para>
  70.         /// Specifies the default value, which is <see cref='System.ComponentModel.LocalizableAttribute.No'/> , that is
  71.         /// a property should not be localized. This <see langword='static '/>field is
  72.         /// read-only.
  73.         /// </para>
  74.         /// </devdoc>
  75.         public static readonly LocalizableAttribute Default = No;
  76.        
  77.         /// <internalonly/>
  78.         /// <devdoc>
  79.         /// </devdoc>
  80.         public override bool IsDefaultAttribute()
  81.         {
  82.             return (IsLocalizable == Default.IsLocalizable);
  83.         }
  84.        
  85.         public override bool Equals(object obj)
  86.         {
  87.             LocalizableAttribute other = obj as LocalizableAttribute;
  88.             return (other != null) && other.IsLocalizable == this.isLocalizable;
  89.         }
  90.        
  91.         public override int GetHashCode()
  92.         {
  93.             return base.GetHashCode();
  94.         }
  95.     }
  96. }

Developer Fusion