|
1 | | -namespace NetArchTest.Rules |
2 | | -{ |
3 | | - using System; |
4 | | - using System.Collections.Generic; |
5 | | - using System.IO; |
6 | | - using System.Linq; |
7 | | - using System.Reflection; |
8 | | - using System.Runtime.CompilerServices; |
9 | | - using NetArchTest.Rules.Extensions; |
10 | | - using Mono.Cecil; |
11 | | - using NetArchTest.Rules.Dependencies; |
12 | | - using NetArchTest.Rules.Dependencies.DataStructures; |
13 | | - |
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.IO; |
| 4 | +using System.Linq; |
| 5 | +using System.Reflection; |
| 6 | +using System.Runtime.CompilerServices; |
| 7 | +using NetArchTest.Rules.Extensions; |
| 8 | +using Mono.Cecil; |
| 9 | +using NetArchTest.Rules.Dependencies; |
| 10 | +using NetArchTest.Rules.Dependencies.DataStructures; |
| 11 | + |
| 12 | +namespace NetArchTest.Rules |
| 13 | +{ |
14 | 14 | /// <summary> |
15 | 15 | /// Creates a list of types that can have predicates and conditions applied to it. |
16 | 16 | /// </summary> |
@@ -112,48 +112,7 @@ public static Types InAssemblies(IEnumerable<Assembly> assemblies, IEnumerable<s |
112 | 112 | return new Types(types); |
113 | 113 | } |
114 | 114 |
|
115 | | - /// <summary> |
116 | | - /// Creates a list of all the types in a particular namespace. |
117 | | - /// </summary> |
118 | | - /// <param name="name">The namespace to list types for. This is case insensitive.</param> |
119 | | - /// <returns>A list of types that can have predicates and conditions applied to it.</returns> |
120 | | - public static Types InNamespace(string name) |
121 | | - { |
122 | | - if (string.IsNullOrEmpty(name)) |
123 | | - { |
124 | | - throw new ArgumentNullException(nameof(name)); |
125 | | - } |
126 | | - |
127 | | - // We need to check all the assemblies in the domain |
128 | | - var assemblies = AppDomain.CurrentDomain.GetAssemblies(); |
129 | | - var types = new List<TypeDefinition>(); |
130 | | - |
131 | | - foreach (var assembly in assemblies) |
132 | | - { |
133 | | - if (!assembly.IsDynamic) |
134 | | - { |
135 | | - // Load the assembly using Mono.Cecil. |
136 | | - var assemblyDef = ReadAssemblyDefinition(assembly.Location); |
137 | | - |
138 | | - if (assemblyDef != null) |
139 | | - { |
140 | | - // Read all the types in the assembly |
141 | | - var matches = (assemblyDef.Modules |
142 | | - .SelectMany(t => t.Types) |
143 | | - .Where(t => t.Namespace != null && t.Namespace.StartsWith(name, StringComparison.InvariantCultureIgnoreCase))) |
144 | | - .ToList(); |
145 | | - |
146 | | - if (matches.Count > 0) |
147 | | - { |
148 | | - types.AddRange(matches); |
149 | | - } |
150 | | - } |
151 | | - } |
152 | | - } |
153 | | - |
154 | | - var list = Types.GetAllTypes(types); |
155 | | - return new Types(list); |
156 | | - } |
| 115 | + |
157 | 116 |
|
158 | 117 | /// <summary> |
159 | 118 | /// Creates a list of all the types in a particular module file. |
|
0 commit comments