private MethodInfo ResolveMethodInternal(Type clazz, String methodName, MethodModifiers methodModifiers)
        {
            MethodInfo[] methods      = clazz.GetMethods();
            MethodInfo   methodByName = null;

            // check each method by name
            foreach (MethodInfo method in methods.Where(m => m.Name == methodName))
            {
                if (methodByName != null)
                {
                    throw new EngineImportException(string.Format("Ambiguous method name: method by name '{0}' is overloaded in class '{1}'", methodName, clazz.FullName));
                }

                var isPublic = method.IsPublic;
                var isStatic = method.IsStatic;
                if (methodModifiers.AcceptsPublicFlag(isPublic) && methodModifiers.AcceptsStaticFlag(isStatic))
                {
                    methodByName = method;
                }
            }

            if (methodByName == null)
            {
                throw new EngineImportException("Could not find " + methodModifiers.Text + " method named '" + methodName + "' in class '" + clazz.FullName + "'");
            }
            return(methodByName);
        }
        private MethodInfo ResolveMethodInternalCheckOverloads(
            Type clazz,
            string methodName,
            MethodModifiers methodModifiers)
        {
            MethodInfo[]      methods      = clazz.GetMethods();
            ISet <MethodInfo> overloadeds  = null;
            MethodInfo        methodByName = null;

            // check each method by name, add to overloads when multiple methods for the same name
            foreach (var method in methods)
            {
                if (method.Name.Equals(methodName))
                {
                    bool isPublic = method.IsPublic;
                    bool isStatic = method.IsStatic;
                    if (methodModifiers.AcceptsPublicFlag(isPublic) && methodModifiers.AcceptsStaticFlag(isStatic))
                    {
                        if (methodByName != null)
                        {
                            if (overloadeds == null)
                            {
                                overloadeds = new HashSet <MethodInfo>();
                            }

                            overloadeds.Add(method);
                        }
                        else
                        {
                            methodByName = method;
                        }
                    }
                }
            }

            if (methodByName == null)
            {
                throw new ImportException("Could not find " + methodModifiers.Text + " method named '" + methodName + "' in class '" + clazz.Name + "'");
            }

            if (overloadeds == null)
            {
                return(methodByName);
            }

            // determine that all overloads have the same result type
            foreach (var overloaded in overloadeds)
            {
                if (overloaded.ReturnType != methodByName.ReturnType)
                {
                    throw new ImportException(
                              "Method by name '" + methodName + "' is overloaded in class '" + clazz.Name + "' and overloaded methods do not return the same type");
                }
            }

            return(methodByName);
        }