Inheritance: NVTypeNode
        public List<NVClassNode> GetHelpers()
        {
            List<string> assemblies = GetAssembliesInBinaryDirectory();
            List<NVClassNode> types = new List<NVClassNode>();
            foreach (string assemblyFileName in assemblies)
            {
                if (!IsIgnored(assemblyFileName))
                {
                    AssemblyDefinition assemblyDefinition = AssemblyFactory.GetAssembly(assemblyFileName);
                    TypeDefinitionCollection typeDefs = assemblyDefinition.MainModule.Types;
                    foreach (TypeDefinition type in typeDefs)
                    {
                        if (type.Name != "<Module>" &&
                            !type.IsAbstract &&
                            type.BaseType != null &&
                            TypeInherits(typeDefs, type, AbstractHelperTypeName))
                        {
                            NVClassNode classNode = new NVClassNode(type.Name, type.FullName);
                            classNode.ClassPurpose = NVClassNodePurpose.Helper;
                            classNode.AssemblyFileName = assemblyFileName;

                            foreach (MethodDefinition method in type.Methods)
                            {
                                // Properties have the special name IL flag so ignore get_ and set_ methods
                                if ((method.Attributes & MethodAttributes.Public) == MethodAttributes.Public &&
                                    method.SemanticsAttributes != MethodSemanticsAttributes.Getter &&
                                    method.SemanticsAttributes != MethodSemanticsAttributes.Setter)
                                {
                                    NVMethodNode methodNode = new NVMethodNode(method.Name, new NVClassNode(
                                        method.ReturnType.ReturnType.Name, method.ReturnType.ReturnType.FullName));

                                    List<NVParameterNode> parameters = new List<NVParameterNode>();
                                    foreach (ParameterDefinition parameter in method.Parameters)
                                    {
                                        parameters.Add(new NVParameterNode(
                                            parameter.Name,
                                            new NVClassNode(parameter.ParameterType.Name,
                                                parameter.ParameterType.FullName),
                                            parameter.Sequence));
                                    }
                                    methodNode.Parameters = parameters;

                                    classNode.AddMethod(methodNode);
                                }
                            }
                            types.Add(classNode);
                        }
                    }
                }
            }

            return types;
        }
Exemple #2
0
 public void AddClass(NVClassNode classNode)
 {
     _classes.Add(classNode);
 }
        public List<NVClassNode> GetViewComponents()
        {
            List<string> assemblies = GetAssembliesInBinaryDirectory();
            List<NVClassNode> types = new List<NVClassNode>();
            foreach (string assemblyFileName in assemblies)
            {
                if (!IsIgnored(assemblyFileName))
                {
                    AssemblyDefinition assemblyDefinition = AssemblyFactory.GetAssembly(assemblyFileName);
                    TypeDefinitionCollection typeDefs = assemblyDefinition.MainModule.Types;
                    foreach (TypeDefinition type in typeDefs)
                    {
                        if (type.Name != "<Module>" &&
                            !type.IsAbstract &&
                            type.BaseType != null &&
                            TypeInherits(typeDefs, type, ViewComponentTypeName))
                        {
                            NVClassNode classNode = new NVClassNode(type.Name, type.FullName);
                            classNode.ClassPurpose = NVClassNodePurpose.ViewComponent;
                            classNode.AssemblyFileName = assemblyFileName;
                            types.Add(classNode);
                        }
                    }
                }
            }

            return types;
        }