| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- //
- // System.ComponentModel.DefaultValueAttribute
- //
- // Authors:
- // Andreas Nahr ([email protected])
- //
- // (C) 2003 Andreas Nahr
- //
- namespace System.ComponentModel
- {
- [AttributeUsage(AttributeTargets.All)]
- public sealed class DefaultValueAttribute : Attribute
- {
- private object DefaultValue;
- public DefaultValueAttribute (bool value)
- {
- DefaultValue = value;
- }
- public DefaultValueAttribute (byte value)
- {
- DefaultValue = value;
- }
- public DefaultValueAttribute (char value)
- {
- DefaultValue = value;
- }
- public DefaultValueAttribute (double value)
- {
- DefaultValue = value;
- }
- public DefaultValueAttribute (short value)
- {
- DefaultValue = value;
- }
- public DefaultValueAttribute (int value)
- {
- DefaultValue = value;
- }
- public DefaultValueAttribute (long value)
- {
- DefaultValue = value;
- }
- public DefaultValueAttribute (object value)
- {
- DefaultValue = value;
- }
- public DefaultValueAttribute (float value)
- {
- DefaultValue = value;
- }
- public DefaultValueAttribute (string value)
- {
- DefaultValue = value;
- }
- public DefaultValueAttribute (Type type, string value)
- {
- // TODO check if this implementation is correct
- try
- {
- DefaultValue = Convert.ChangeType (value, type);
- }
- catch
- {
- DefaultValue = null;
- }
- }
- public object Value
- {
- get { return DefaultValue; }
- }
- public override bool Equals (object obj)
- {
- if (!(obj is DefaultValueAttribute))
- return false;
- if (obj == this)
- return true;
- return ((DefaultValueAttribute) obj).Value == DefaultValue;
- }
- public override int GetHashCode()
- {
- return DefaultValue.GetHashCode();
- }
- }
- }
- // OLD IMPLEMENTATION
- //using System;
- //
- //
- //
- //namespace System.ComponentModel
- //
- //{
- //
- // /// <summary>
- //
- // /// Specifies the default value for a property.
- //
- // /// </summary>
- //
- //
- //
- // [MonoTODO("Needs testing. DefaultValueAttribute(System.Type type, string value) is not implemented. Value has no description.")]
- //
- // [AttributeUsage(AttributeTargets.All)]
- //
- // public sealed class DefaultValueAttribute : Attribute
- //
- // {
- //
- //
- //
- // private object defaultValue;
- //
- //
- //
- // /// <summary>
- //
- // /// FIXME: Summary description for Value.
- //
- // /// </summary>
- //
- // public object Value
- //
- // {
- //
- // get
- //
- // {
- //
- // return defaultValue;
- //
- // }
- //
- // }
- //
- //
- //
- // /// <summary>
- //
- // /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class.
- //
- // /// </summary>
- //
- // /// <param name="value">An System.Object that represents the default value.</param>
- //
- // public DefaultValueAttribute(object value)
- //
- // {
- //
- // defaultValue = value;
- //
- // }
- //
- //
- //
- // /// <summary>
- //
- // /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a System.Boolean value.
- //
- // /// </summary>
- //
- // /// <param name="value">An System.Boolean that represents the default value.</param>
- //
- // public DefaultValueAttribute(bool value)
- //
- // {
- //
- // defaultValue = value;
- //
- // }
- //
- //
- //
- //
- //
- // /// <summary>
- //
- // /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using an 8-bit unsigned integer.
- //
- // /// </summary>
- //
- // /// <param name="value">An 8-bit unsigned integer that is the default value.</param>
- //
- // public DefaultValueAttribute(byte value)
- //
- // {
- //
- // defaultValue = value;
- //
- // }
- //
- //
- //
- // /// <summary>
- //
- // /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a Unicode character.
- //
- // /// </summary>
- //
- // /// <param name="value">A Unicode character that is the default value.</param>
- //
- // public DefaultValueAttribute(char value)
- //
- // {
- //
- // defaultValue = value;
- //
- // }
- //
- //
- //
- // /// <summary>
- //
- // /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a double-precision floating point number.
- //
- // /// </summary>
- //
- // /// <param name="value">A double-precision floating point number that is the default value.</param>
- //
- // public DefaultValueAttribute(double value)
- //
- // {
- //
- // defaultValue = value;
- //
- // }
- //
- //
- //
- // /// <summary>
- //
- // /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a 32-bit signed integer.
- //
- // /// </summary>
- //
- // /// <param name="value">A 32-bit signed integer that is the default value.</param>
- //
- // public DefaultValueAttribute(int value)
- //
- // {
- //
- // defaultValue = value;
- //
- // }
- //
- //
- //
- // /// <summary>
- //
- // /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a 64-bit signed integer.
- //
- // /// </summary>
- //
- // /// <param name="value">A 64-bit signed integer that is the default value.</param>
- //
- // public DefaultValueAttribute(long value)
- //
- // {
- //
- // defaultValue = value;
- //
- // }
- //
- //
- //
- // /// <summary>
- //
- // /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a 16-bit signed integer.
- //
- // /// </summary>
- //
- // /// <param name="value">A 16-bit signed integer that is the default value.</param>
- //
- // public DefaultValueAttribute(short value)
- //
- // {
- //
- // defaultValue = value;
- //
- // }
- //
- //
- //
- // /// <summary>
- //
- // /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a single-precision floating point number.
- //
- // /// </summary>
- //
- // /// <param name="value">A single-precision floating point number that is the default value.</param>
- //
- // public DefaultValueAttribute(System.Single value)
- //
- // {
- //
- // defaultValue = value;
- //
- // }
- //
- //
- //
- // /// <summary>
- //
- // /// Initializes a new instance of the System.ComponentModel.DefaultValueAttribute class using a System.String.
- //
- // /// </summary>
- //
- // /// <param name="value">A System.String that is the default value.</param>
- //
- // public DefaultValueAttribute(string value)
- //
- // {
- //
- // defaultValue = value;
- //
- // }
- //
- //
- //
- // /*
- //
- // /// <summary>
- //
- // /// 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.
- //
- // /// </summary>
- //
- // /// <param name="type">A System.Type that represents the type to convert the value to.</param>
- //
- // /// <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>
- //
- // public DefaultValueAttribute(System.Type type, string value)
- //
- // {
- //
- // //FIXME
- //
- // throw new NotImplementedException();
- //
- // }
- //
- // */
- //
- // }
- //
- //
- //
- //}
|