DefaultValueAttribute.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System;
  2. namespace System.ComponentModel
  3. {
  4. /// <summary>
  5. /// Specifies the default value for a property.
  6. /// </summary>
  7. [MonoTODO("Needs testing. DefaultValueAttribute(System.Type type, string value) is not implemented. Value has no description.")]
  8. [AttributeUsage(AttributeTargets.Parameter)]
  9. public sealed class DefaultValueAttribute : Attribute
  10. {
  11. private object defaultValue;
  12. /// <summary>
  13. /// FIXME: Summary description for Value.
  14. /// </summary>
  15. public object Value
  16. {
  17. get
  18. {
  19. return defaultValue;
  20. }
  21. }
  22. /// <summary>
  23. /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class.
  24. /// </summary>
  25. /// <param name="value">An System.Object that represents the default value.</param>
  26. public DefaultValueAttribute(object value)
  27. {
  28. defaultValue = value;
  29. }
  30. /// <summary>
  31. /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a System.Boolean value.
  32. /// </summary>
  33. /// <param name="value">An System.Boolean that represents the default value.</param>
  34. public DefaultValueAttribute(bool value)
  35. {
  36. defaultValue = value;
  37. }
  38. /// <summary>
  39. /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using an 8-bit unsigned integer.
  40. /// </summary>
  41. /// <param name="value">An 8-bit unsigned integer that is the default value.</param>
  42. public DefaultValueAttribute(byte value)
  43. {
  44. defaultValue = value;
  45. }
  46. /// <summary>
  47. /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a Unicode character.
  48. /// </summary>
  49. /// <param name="value">A Unicode character that is the default value.</param>
  50. public DefaultValueAttribute(char value)
  51. {
  52. defaultValue = value;
  53. }
  54. /// <summary>
  55. /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a double-precision floating point number.
  56. /// </summary>
  57. /// <param name="value">A double-precision floating point number that is the default value.</param>
  58. public DefaultValueAttribute(double value)
  59. {
  60. defaultValue = value;
  61. }
  62. /// <summary>
  63. /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a 32-bit signed integer.
  64. /// </summary>
  65. /// <param name="value">A 32-bit signed integer that is the default value.</param>
  66. public DefaultValueAttribute(int value)
  67. {
  68. defaultValue = value;
  69. }
  70. /// <summary>
  71. /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a 64-bit signed integer.
  72. /// </summary>
  73. /// <param name="value">A 64-bit signed integer that is the default value.</param>
  74. public DefaultValueAttribute(long value)
  75. {
  76. defaultValue = value;
  77. }
  78. /// <summary>
  79. /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a 16-bit signed integer.
  80. /// </summary>
  81. /// <param name="value">A 16-bit signed integer that is the default value.</param>
  82. public DefaultValueAttribute(short value)
  83. {
  84. defaultValue = value;
  85. }
  86. /// <summary>
  87. /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a single-precision floating point number.
  88. /// </summary>
  89. /// <param name="value">A single-precision floating point number that is the default value.</param>
  90. public DefaultValueAttribute(System.Single value)
  91. {
  92. defaultValue = value;
  93. }
  94. /// <summary>
  95. /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a System.String.
  96. /// </summary>
  97. /// <param name="value">A System.String that is the default value.</param>
  98. public DefaultValueAttribute(string value)
  99. {
  100. defaultValue = value;
  101. }
  102. /*
  103. /// <summary>
  104. /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class, converting the specified value to the specified type, and using an invariant culture as the translation context.
  105. /// </summary>
  106. /// <param name="type">A System.Type that represents the type to convert the value to.</param>
  107. /// <param name="value">A System.String that can be converted to the type using the System.ComponentModel.TypeConverter for the type and the U.S. English culture.</param>
  108. public DefaultValueAttribute(System.Type type, string value)
  109. {
  110. //FIXME
  111. throw new NotImplementedException();
  112. }
  113. */
  114. }
  115. }