void AddType(TypeDefinition type, Action<ModelType, string> add) { MetadataReader reader = _reader.Value.Reader; ModelType modelType = new ModelType { Name = reader.GetString(type.Name) }; add(modelType, reader.GetString(type.Namespace)); foreach (var hmember in type.GetFields()) { FieldDefinition member = reader.GetFieldDefinition(hmember); modelType.Members.Add(new ModelTypeMember { Name = "[f] " + reader.GetString(member.Name) }); } foreach (var hmember in type.GetMethods()) { MethodDefinition member = reader.GetMethodDefinition(hmember); modelType.Members.Add(new ModelMethod { Name = reader.GetString(member.Name) + "()", Handle = hmember, Type = type, }); } foreach (var hchild in type.GetNestedTypes()) { TypeDefinition child = reader.GetTypeDefinition(hchild); AddType(child, (m, typeNs) => modelType.Members.Add(m)); } }
void AddModelType(ModelFile file, string typeNs, ModelType m) { ModelNamespace modelNs = file.Namespaces.Find(x => x.Name == typeNs); if (modelNs == null) { file.Namespaces.Add(modelNs = new ModelNamespace { Name = typeNs }); } modelNs.Types.Add(m); }
void AddType(TreeNodeCollection parent, ModelType type) { var typenode = parent.Add(type.Name); foreach (var member in type.Members) { var childt = member as ModelType; if (childt != null) { AddType(typenode.Nodes, childt); } else { var memberNode = typenode.Nodes.Add(member.Name); memberNode.Tag = member; } } }