Archive Browser
Download CustomTypeConverter3.zip version 1.0.0.0, last updated 28/07/2013 (14.36 KB)
Download- md5: 12dfe9b74b052e3c18cd0c878b92b8f9
using System.ComponentModel;
using System.Globalization;
/*
Custom Type Converter Sample 3
http://cyotek.com/blog/using-alternate-descriptions-for-enumeration-members
*/
namespace CustomTypeConverter3
{
[TypeConverter(typeof(LengthConverter))]
internal class Length
{
#region Constructors
public Length()
{ }
public Length(float value, Unit unit)
: this()
{
this.Value = value;
this.Unit = unit;
}
#endregion
#region Overridden Members
public override string ToString()
{
string value;
string unit;
value = this.Value.ToString(CultureInfo.InvariantCulture);
unit = this.Unit.GetDescription();
return string.Concat(value, unit);
}
#endregion
#region Properties
[DefaultValue(typeof(Unit), "None")]
public Unit Unit { get; set; }
[DefaultValue(0F)]
public float Value { get; set; }
#endregion
}
}
Donate
This software may be used free of charge, but as with all free software there are costs involved to develop and maintain.
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Donate