Пример #1
0
        internal static void ReflectMethod(ErrorCollector collector, AstNode where, string type_name, string method_name, int arity, List <System.Reflection.MethodInfo> methods)
        {
            var reflected_type = System.Type.GetType(type_name, false);

            if (reflected_type == null)
            {
                collector.RawError(where, "No such type " + type_name + " found. Perhaps you are missing an assembly reference.");
            }
            else
            {
                foreach (var method in reflected_type.GetMethods())
                {
                    var adjusted_arity = method.GetParameters().Length + (method.IsStatic ? 0 : 1);
                    if (method.Name == method_name && adjusted_arity == arity && !method.IsGenericMethod && !method.IsGenericMethodDefinition && AllInParameteres(method))
                    {
                        methods.Add(method);
                    }
                }
                if (methods.Count == 0)
                {
                    collector.RawError(where, "The type " + type_name + " has no public method named " + method_name + " which takes " + arity + " parameters.");
                }
            }
        }