RFID.RFIDInterface.Source_GPIOList_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_GPIOList gpioList = value as Source_GPIOList;

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

                StringBuilder sb = new StringBuilder( );

                foreach ( Source_GPIO gpio in gpioList )
                {
                    Object obj = TypeDescriptor.GetConverter( typeof( Source_GPIO ) ).ConvertToString( gpio );

                    if ( null == obj )
                    {
                        // Should NOT be possible ~ should get exception for bad arg
                        // before seeing a null == obj return value
                    }
                    else
                    {
                        sb.Append( obj as String );
                        sb.Append( ';' );
                    }
                }

                return sb.ToString( );
            }

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