RFID.RFIDInterface.Source_Antenna_TypeConverter.ConvertTo C# (CSharp) Method

ConvertTo() public method

public ConvertTo ( System context, System culture, object value, Type destinationType ) : object
context System
culture System
value object
destinationType System.Type
return object
        public override object ConvertTo(
            System.ComponentModel.ITypeDescriptorContext context,
            System.Globalization.CultureInfo             culture,
            object                                       value,
            Type                                         destinationType
        )
        {
            if ( typeof( string ) == destinationType )
            {
                Source_Antenna antenna = value as Source_Antenna;

                if ( null == antenna )
                {
                    throw new ArgumentException( "Expected a Source_Antenna", "value" );
                }

                StringBuilder sb = new StringBuilder( );

                sb.AppendFormat
                (
                    "{0},{1},{2},{3},{4},{5}", // ,{7}", if with threshold value
                    antenna.Port,
                    antenna.State,
                    antenna.PowerLevel,
                    antenna.DwellTime,
                    antenna.NumberInventoryCycles,
                    antenna.PhysicalPort
                    //antenna.AntennaSenseThreshold
                );

                return sb.ToString( );
            }

            return base.ConvertTo( context, culture, value, destinationType );
        }
Source_Antenna_TypeConverter