View Single Post
Old 02-01-2007, 11:21 PM   #20 (permalink)
seirge
Newbie
 
Join Date: Aug 2004
Age: 24
Posts: 35
Default

here is it:
Code:
#if MONO
                public static List<TOutput> CastConvertList<TInput, TOutput>( List<TInput> list ) 
                       where TInput : class
                       where TOutput : class
                {
                        return list.ConvertAll<TOutput>( new Converter<TInput, TOutput>( delegate( TInput value ) { return value as TOutput; } ) );
                }

#else
                public static List<TOutput> CastConvertList<TInput, TOutput>( List<TInput> list ) where TOutput : TInput
                {
                        return list.ConvertAll<TOutput>( new Converter<TInput, TOutput>( delegate( TInput value ) { return (TOutput)value; } ) );
                }

#endif
Is is bad solution, but it is the only way to force it to work under mono for now. (it is bad, because if will be used to convert wrong types it will throw exception runtime, not on compilation stage)
Of course, you should define MONO symbol while compiling.
seirge is offline   Reply With Quote