Beispiel #1
0
        private MethodRepresentation mrep(MethodInfo method)
        {
            if (method.IsPrivate || method.IsAssembly || method.IsSpecialName)
            {
                return(null);
            }
            string               name       = method.Name;
            ObjectType           returnType = ObjectType.toObjectType(method.ReturnType);
            MethodRepresentation methodRep  = new MethodRepresentation(returnType, name);

            if (method.DeclaringType != method.ReflectedType)
            {
                methodRep.inheritedFrom = method.DeclaringType.FullName;
            }
            if (method.IsGenericMethod)
            {
                Type[]        gens    = method.GetGenericArguments();
                List <string> genArgs = new List <string>();
                foreach (Type genType in gens)
                {
                    object[] constraints = genType.GetGenericParameterConstraints();
                    string   argString   = genType.ToString();
                    if (constraints.Count() > 0)
                    {
                        argString += ":" + string.Join(",", constraints);
                    }
                    genArgs.Add(argString);
                }
                methodRep.genericArgs = genArgs;
            }
            methodRep.modifiers.Add(convert(method));
            methodRep.attributes = getAttributes(method);
            if (method.IsVirtual)
            {
                methodRep.modifiers.Add(Member.Modifier.VIRTUAL);
            }
            foreach (ParameterInfo param in method.GetParameters())
            {
                ObjectType paramType = ObjectType.toObjectType(param.ParameterType);
                string     paramName = param.Name;
                methodRep.parameters.Add(new Member(paramType, paramName));
            }
            return(methodRep);
        }
Beispiel #2
0
 private void reflectConstructors(ClassRepresentation rep, Type type)
 {
     foreach (ConstructorInfo cons in type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
     {
         if (cons.IsPrivate || cons.IsAssembly)
         {
             continue;
         }
         string               name       = "*constructor*";
         ObjectType           returnType = ObjectType.toObjectType(type);
         MethodRepresentation methodRep  = new MethodRepresentation(returnType, name);
         methodRep.modifiers.Add(convert(cons));
         methodRep.attributes = getAttributes(cons);
         foreach (ParameterInfo param in cons.GetParameters())
         {
             ObjectType paramType = ObjectType.toObjectType(param.ParameterType);
             string     paramName = param.Name;
             methodRep.parameters.Add(new Member(paramType, paramName));
         }
         rep.constructors.Add(methodRep);
     }
 }
Beispiel #3
0
        private void reflectMethods(ClassRepresentation rep, Type type)
        {
            foreach (MethodInfo method in type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
            {
                MethodRepresentation methodRep = mrep(method);
                if (methodRep == null)
                {
                    continue;
                }
                rep.instanceMethods.Add(methodRep);
            }

            foreach (MethodInfo method in type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
            {
                MethodRepresentation methodRep = mrep(method);
                if (methodRep == null)
                {
                    continue;
                }
                methodRep.modifiers.Add(Member.Modifier.STATIC);
                rep.staticMethods.Add(methodRep);
            }
        }