예제 #1
0
        private static MethodInfo DetermineFactoryMethod(Type targetClass, Type sourceClass)
        {
            if (typeof(string) == targetClass)
            {
                // Do not accept the String.valueOf(Object) method
                return(null);
            }

            var method = ConversionUtils.GetStaticMethod(targetClass, "ValueOf", sourceClass);

            if (method == null)
            {
                method = ConversionUtils.GetStaticMethod(targetClass, "Of", sourceClass);
                if (method == null)
                {
                    method = ConversionUtils.GetStaticMethod(targetClass, "From", sourceClass);
                }
            }

            return(method);
        }