diff options
author | jbevain <jbevain@gmail.com> | 2011-05-06 20:01:40 +0400 |
---|---|---|
committer | jbevain <jbevain@gmail.com> | 2011-05-06 20:01:40 +0400 |
commit | 96e996076d2a97cc3565cb40048b576dc777591d (patch) | |
tree | f16a8686e6d69f1bf6cddd1c15732cbac521f96d /Mono.Cecil | |
parent | bd8e003e01bf718407a9e89d446c2469fb28a4c7 (diff) |
By popular demand, add a GetTypes to Module to iterate over every Type
Diffstat (limited to 'Mono.Cecil')
-rw-r--r-- | Mono.Cecil/ModuleDefinition.cs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Mono.Cecil/ModuleDefinition.cs b/Mono.Cecil/ModuleDefinition.cs index 7fecf74..ecfbf82 100644 --- a/Mono.Cecil/ModuleDefinition.cs +++ b/Mono.Cecil/ModuleDefinition.cs @@ -498,6 +498,26 @@ namespace Mono.Cecil { return ((TypeDefinitionCollection) this.Types).GetType (@namespace ?? string.Empty, name); } + public IEnumerable<TypeDefinition> GetTypes () + { + return GetTypes (Types); + } + + static IEnumerable<TypeDefinition> GetTypes (Collection<TypeDefinition> types) + { + for (int i = 0; i < types.Count; i++) { + var type = types [i]; + + yield return type; + + if (!type.HasNestedTypes) + continue; + + foreach (var nested in GetTypes (type.NestedTypes)) + yield return nested; + } + } + static void CheckFullName (string fullName) { if (fullName == null) |