ConfigurationProperty.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // System.Configuration.ConfigurationUpdateMode.cs
  3. //
  4. // Authors:
  5. // Duncan Mak ([email protected])
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining
  8. // a copy of this software and associated documentation files (the
  9. // "Software"), to deal in the Software without restriction, including
  10. // without limitation the rights to use, copy, modify, merge, publish,
  11. // distribute, sublicense, and/or sell copies of the Software, and to
  12. // permit persons to whom the Software is furnished to do so, subject to
  13. // the following conditions:
  14. //
  15. // The above copyright notice and this permission notice shall be
  16. // included in all copies or substantial portions of the Software.
  17. //
  18. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  22. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  23. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  24. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. //
  26. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  27. //
  28. #if NET_2_0
  29. #if XML_DEP
  30. using System;
  31. using System.ComponentModel;
  32. namespace System.Configuration
  33. {
  34. public class ConfigurationProperty : ConfigurationElement
  35. {
  36. string name;
  37. Type type;
  38. object default_value;
  39. TypeConverter converter;
  40. ConfigurationValidationAttribute validation;
  41. ConfigurationPropertyFlags flags;
  42. public ConfigurationProperty (string name, Type type, object default_value)
  43. : this (name, type, default_value, ConfigurationPropertyFlags.None)
  44. {
  45. }
  46. public ConfigurationProperty (
  47. string name, Type type, object default_value,
  48. ConfigurationPropertyFlags flags)
  49. :this (name, type, default_value, TypeDescriptor.GetConverter (type), null, flags)
  50. {
  51. }
  52. public ConfigurationProperty (
  53. string name, Type type, object default_value,
  54. TypeConverter converter,
  55. ConfigurationValidationAttribute validation,
  56. ConfigurationPropertyFlags flags)
  57. {
  58. this.name = name;
  59. this.converter = converter;
  60. this.default_value = default_value;
  61. this.flags = flags;
  62. this.type = type;
  63. this.validation = validation;
  64. }
  65. public TypeConverter Converter {
  66. get { return converter; }
  67. }
  68. public object DefaultValue {
  69. get { return default_value; }
  70. }
  71. public bool IsKey {
  72. get { return (flags & ConfigurationPropertyFlags.IsKey) != 0; }
  73. }
  74. public bool IsRequired {
  75. get { return (flags & ConfigurationPropertyFlags.Required) != 0; }
  76. }
  77. public string Name {
  78. get { return name; }
  79. }
  80. public Type Type {
  81. get { return type; }
  82. }
  83. public ConfigurationValidationAttribute ValidationAttribute {
  84. get { return validation; }
  85. }
  86. [MonoTODO]
  87. protected internal virtual object ConvertFromString (string value)
  88. {
  89. throw new NotImplementedException ();
  90. }
  91. [MonoTODO]
  92. protected internal virtual string ConvertToString (object value)
  93. {
  94. throw new NotImplementedException ();
  95. }
  96. }
  97. }
  98. #endif
  99. #endif