Beispiel #1
0
        } // End of ImpConvertToType (...)

        protected virtual Object ImpConvertToType(Object sourceValue, Type targetType)
        {
            String             oldCnvStrValue  = null;
            IConvertibleString stringConverter = null;

            if (sourceValue == null)
            {
                return(null);
            }
            if (targetType == null)
            {
                return(sourceValue);
            }
            if (ImplAdapter == null)
            {
                return(sourceValue);
            }
            if ((stringConverter = ImplAdapter.Converter) == null)
            {
                return(sourceValue);
            }

            oldCnvStrValue = stringConverter.StringValue;

            try
            {
                stringConverter.StringValue = sourceValue.ToString();

                return(stringConverter.ToType(targetType, null));
            }
            finally { stringConverter.StringValue = oldCnvStrValue; }
        } // End of ImpConvertToType (...)
Beispiel #2
0
        //protected virtual Object ImpConvertToType ( IConvertible converter, Type targetType )
        //{
        //    if ( converter  == null ) return null;
        //    if ( targetType == null ) return null;

        //    return converter.ToType ( targetType, null );
        //} // End of ImpConvertToType (...)

        protected virtual Object ImpConvertToType(IConvertibleString stringConverter, Type targetType)
        {
            if (stringConverter == null)
            {
                return(null);
            }
            if (targetType == null)
            {
                return(null);
            }

            return(stringConverter.ToType(targetType, null));
        } // End of ImpConvertToType (...)