public override object ConvertTo(
System.ComponentModel.ITypeDescriptorContext context,
System.Globalization.CultureInfo culture,
object value,
Type destinationType
)
{
if ( typeof( string ) == destinationType )
{
Source_GPIO gpio = value as Source_GPIO;
if ( null == gpio )
{
throw new ArgumentException( "Expected a Source_GPIO", "value" );
}
StringBuilder sb = new StringBuilder( );
// Assume is GET access then state shouldn't be stored i.e. radio state
// retrieval should be done. If SET access, then keep state...
if ( Source_GPIO.OpAccess.GET == gpio.Access )
{
sb.AppendFormat( "{0},{1}", ( Int32 ) gpio.nativePin, ( Int32 ) gpio.Access );
}
else
{
sb.AppendFormat( "{0},{1},{2}", ( Int32 ) gpio.nativePin, ( Int32 ) gpio.Access, ( Int32 ) gpio.State );
}
return sb.ToString( );
}
return base.ConvertTo( context, culture, value, destinationType );
}