The Labs \ Source Viewer \ SSCLI \ System.Configuration \ ConfigurationPropertyAttribute

  1. //------------------------------------------------------------------------------
  2. // <copyright file="ConfigurationPropertyAttribute.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. using System;
  16. using System.Configuration.Internal;
  17. using System.Collections;
  18. using System.Collections.Specialized;
  19. using System.Collections.Generic;
  20. using System.IO;
  21. using System.Reflection;
  22. using System.Security.Permissions;
  23. using System.Xml;
  24. using System.Globalization;
  25. using System.ComponentModel;
  26. using System.Security;
  27. using System.Text;
  28. namespace System.Configuration
  29. {
  30.    
  31.     [AttributeUsage(AttributeTargets.Property)]
  32.     public sealed class ConfigurationPropertyAttribute : Attribute
  33.     {
  34.         static internal readonly string DefaultCollectionPropertyName = "";
  35.        
  36.         private string _Name;
  37.         private object _DefaultValue = ConfigurationElement.s_nullPropertyValue;
  38.         private ConfigurationPropertyOptions _Flags = ConfigurationPropertyOptions.None;
  39.        
  40.         public ConfigurationPropertyAttribute(string name)
  41.         {
  42.             _Name = name;
  43.         }
  44.        
  45.         public string Name {
  46.             get { return _Name; }
  47.         }
  48.        
  49.         public object DefaultValue {
  50.             get { return _DefaultValue; }
  51.             set { _DefaultValue = value; }
  52.         }
  53.        
  54.         public ConfigurationPropertyOptions Options {
  55.             get { return _Flags; }
  56.             set { _Flags = value; }
  57.         }
  58.        
  59.         public bool IsDefaultCollection {
  60.             get { return ((Options & ConfigurationPropertyOptions.IsDefaultCollection) != 0); }
  61.             set {
  62.                 if (value == true) {
  63.                     Options |= ConfigurationPropertyOptions.IsDefaultCollection;
  64.                 }
  65.                 else
  66.                     Options &= ~ConfigurationPropertyOptions.IsDefaultCollection;
  67.             }
  68.         }
  69.        
  70.         public bool IsRequired {
  71.             get { return ((Options & ConfigurationPropertyOptions.IsRequired) != 0); }
  72.             set {
  73.                 if (value == true) {
  74.                     Options |= ConfigurationPropertyOptions.IsRequired;
  75.                 }
  76.                 else {
  77.                     Options &= ~ConfigurationPropertyOptions.IsRequired;
  78.                 }
  79.             }
  80.         }
  81.        
  82.         public bool IsKey {
  83.             get { return ((Options & ConfigurationPropertyOptions.IsKey) != 0); }
  84.             set {
  85.                 if (value == true) {
  86.                     Options |= ConfigurationPropertyOptions.IsKey;
  87.                 }
  88.                 else {
  89.                     Options &= ~ConfigurationPropertyOptions.IsKey;
  90.                 }
  91.             }
  92.         }
  93.     }
  94. }

Developer Fusion