The Labs \ Source Viewer \ SSCLI \ System \ AttributeUsageAttribute

  1. // ==++==
  2. //
  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. //
  14. // ==--==
  15. /*============================================================
  16. **
  17. ** Class:  AttributeUsageAttribute
  18. **
  19. **
  20. ** Purpose: The class denotes how to specify the usage of an attribute
  21. **         
  22. **
  23. ===========================================================*/
  24. namespace System
  25. {
  26.    
  27.     using System.Reflection;
  28. /* By default, attributes are inherited and multiple attributes are not allowed */   
  29.     [AttributeUsage(AttributeTargets.Class, Inherited = true), Serializable()]
  30.     [System.Runtime.InteropServices.ComVisible(true)]
  31.     public sealed class AttributeUsageAttribute : Attribute
  32.     {
  33.         internal AttributeTargets m_attributeTarget = AttributeTargets.All;
  34.         // Defaults to all
  35.         internal bool m_allowMultiple = false;
  36.         // Defaults to false
  37.         internal bool m_inherited = true;
  38.         // Defaults to true
  39.         static internal AttributeUsageAttribute Default = new AttributeUsageAttribute(AttributeTargets.All);
  40.        
  41.         //Constructors
  42.         public AttributeUsageAttribute(AttributeTargets validOn)
  43.         {
  44.             m_attributeTarget = validOn;
  45.         }
  46.         internal AttributeUsageAttribute(AttributeTargets validOn, bool allowMultiple, bool inherited)
  47.         {
  48.             m_attributeTarget = validOn;
  49.             m_allowMultiple = allowMultiple;
  50.             m_inherited = inherited;
  51.         }
  52.        
  53.        
  54.         //Properties
  55.         public AttributeTargets ValidOn {
  56.             get { return m_attributeTarget; }
  57.         }
  58.        
  59.         public bool AllowMultiple {
  60.             get { return m_allowMultiple; }
  61.             set { m_allowMultiple = value; }
  62.         }
  63.        
  64.         public bool Inherited {
  65.             get { return m_inherited; }
  66.             set { m_inherited = value; }
  67.         }
  68.     }
  69. }

Developer Fusion