public override object ConvertFrom(
System.ComponentModel.ITypeDescriptorContext context,
System.Globalization.CultureInfo culture,
Object value
)
{
if ( String.IsNullOrEmpty( value as string ) )
{
return null; // TODO : supply err msg
}
String[ ] channelData = ( value as String ).Split( new Char[ ] { ',' } );
if ( null == channelData )
{
return null; // TODO : supply err msg ~ improper arg
}
if ( 8 != channelData.Length )
{
return null; // TODO : supply err msg ~ improper arg count
}
try
{
UInt32 band = UInt32.Parse( channelData[ 0 ] );
Source_FrequencyBand.BandState state =
( Source_FrequencyBand.BandState ) Enum.Parse
(
typeof( Source_FrequencyBand.BandState ),
channelData[ 1 ]
);
UInt16 multiplier = UInt16.Parse( channelData[ 2 ] );
UInt16 divider = UInt16.Parse( channelData[ 3 ] );
UInt16 guardBand = UInt16.Parse( channelData[ 4 ] );
UInt16 maxDACBand = UInt16.Parse( channelData[ 5 ] );
UInt16 affinityBand = UInt16.Parse( channelData[ 6 ] );
UInt16 minDACBand = UInt16.Parse( channelData[ 7 ] );
Source_FrequencyBand channel = new Source_FrequencyBand
(
band,
state,
multiplier,
divider,
minDACBand,
affinityBand,
maxDACBand,
guardBand
);
return channel;
}
catch ( Exception )
{
// TODO : supply err msg ~ bad arg
return null;
}
}