コード例 #1
0
        private EngineImportException Convert(
            Type clazz,
            string methodName,
            Type[] paramTypes,
            EngineNoSuchMethodException e,
            bool isInstance)
        {
            var expected = TypeHelper.GetParameterAsString(paramTypes);
            var message = "Could not find ";
            if (!isInstance)
            {
                message += "static ";
            }
            else
            {
                message += "enumeration method, date-time method or instance ";
            }

            if (paramTypes.Length > 0)
            {
                message += string.Format(
                    "method named '{0}' in class '{1}' with matching parameter number and expected parameter type(s) '{2}'",
                    methodName, clazz.GetCleanName(), expected);
            }
            else
            {
                message += string.Format(
                    "method named '{0}' in class '{1}' taking no parameters", methodName,
                    clazz.GetCleanName());
            }

            if (e.NearestMissMethod != null)
            {
                message += " (nearest match found was '" + e.NearestMissMethod.Name;
                if (e.NearestMissMethod.GetParameterTypes().Length == 0)
                {
                    message += "' taking no parameters";
                }
                else
                {
                    message += "' taking type(s) '" +
                               TypeHelper.GetParameterAsString(e.NearestMissMethod.GetParameterTypes()) + "'";
                }

                message += ")";
            }

            return new EngineImportException(message, e);
        }
コード例 #2
0
        private EngineImportException Convert(
            Type clazz,
            String methodName,
            Type[] paramTypes,
            EngineNoSuchMethodException e,
            bool isInstance)
        {
            var expected = TypeHelper.GetParameterAsString(paramTypes);
            var message  = "Could not find ";

            if (!isInstance)
            {
                message += "static ";
            }
            else
            {
                message += "enumeration method, date-time method or instance ";
            }

            if (paramTypes.Length > 0)
            {
                message += "method named '" + methodName + "' in class '" +
                           clazz.GetTypeNameFullyQualPretty() +
                           "' with matching parameter number and expected parameter type(s) '" + expected + "'";
            }
            else
            {
                message += "method named '" + methodName + "' in class '" +
                           clazz.GetTypeNameFullyQualPretty() + "' taking no parameters";
            }

            if (e.NearestMissMethod != null)
            {
                message += " (nearest match found was '" + e.NearestMissMethod.Name;
                var parameterTypes = e.NearestMissMethod.GetParameterTypes();
                if (parameterTypes.Length == 0)
                {
                    message += "' taking no parameters";
                }
                else
                {
                    message += "' taking type(s) '" +
                               TypeHelper.GetParameterAsString(parameterTypes) + "'";
                }
                message += ")";
            }
            return(new EngineImportException(message, e));
        }