Exemplo n.º 1
0
        public static IEnumerable <TypeInfo> GenerateIlCode(AssemblyDefinition asm)
        {
            List <TypeInfo> types = new List <TypeInfo>();

            //!!!
            //Skip(1) because the <Module> definition is somehow there, before any of the classes
            //It doesn't contain anything - no class members
            //It shouldn't be there because we are iterating through MainModule's types
            //Perhaps a bug in the library
            //!!!
            foreach (TypeDefinition td in asm.MainModule.Types.Skip(1))
            {
                var tinf = SourceCodeFormatter.GetTypeInfo(td);
                types.Add(tinf);
            }
            return(types);
        }
Exemplo n.º 2
0
        public static object ToJSTree(IEnumerable <TypeInfo> types)
        {
            var tree = new
            {
                text     = "Assembly",
                children = types.Select(type =>
                                        new JSTreeNode(type.Name, type.SystemInfo, type.CustomAttributes, SourceCodeFormatter.ResolveType(type))
                {
                    children = new []
                    {
                        new
                        {
                            type    = "folder-field",
                            text    = "Fields",
                            li_attr = new Dictionary <string, string>()
                            {
                                { "class", "smaller-margins" }
                            },
                            children = type.Fields.Select(x =>
                                                          new JSTreeNode(
                                                              x.Name,
                                                              x.SystemInfo,
                                                              AttributesOrEmptyString(x.CustomAttributes),
                                                              SourceCodeFormatter.ResolveType(x)))
                        },
                        new
                        {
                            type    = "folder-property",
                            text    = "Properties",
                            li_attr = new Dictionary <string, string>()
                            {
                                { "class", "smaller-margins" }
                            }, children = type.Properties.Select(x =>
                                                                 new JSTreeNode(
                                                                     x.Name,
                                                                     x.SystemInfo,
                                                                     AttributesOrEmptyString(x.CustomAttributes)
                                                                     + x.GetterInfo
                                                                     + Environment.NewLine + x.SetterInfo,
                                                                     SourceCodeFormatter.ResolveType(x)))
                        },
                        new
                        {
                            type    = "folder-event",
                            text    = "Events",
                            li_attr = new Dictionary <string, string>()
                            {
                                { "class", "smaller-margins" }
                            }, children = type.Events.Select(x =>
                                                             new JSTreeNode(
                                                                 x.Name,
                                                                 x.SystemInfo,
                                                                 AttributesOrEmptyString(x.CustomAttributes)
                                                                 + x.AddOnInfo
                                                                 + Environment.NewLine + x.RemoveOnInfo,
                                                                 SourceCodeFormatter.ResolveType(x)))
                        },
                        new
                        {
                            type    = "folder-method",
                            text    = "Methods",
                            li_attr = new Dictionary <string, string>()
                            {
                                { "class", "smaller-margins" }
                            }, children = type.Methods.Select(x =>
                                                              new JSTreeNode(
                                                                  x.Name,
                                                                  x.SystemInfo,
                                                                  AttributesOrEmptyString(x.CustomAttributes)
                                                                  + x.MethodBody,
                                                                  SourceCodeFormatter.ResolveType(x)))
                        },
                    }
                })
            };

            return(tree);
        }