-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssembliesInParallelFolder.cs
executable file
·63 lines (53 loc) · 1.71 KB
/
AssembliesInParallelFolder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using Mono.Cecil;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GenerateEXamlTool
{
public class AssembliesInParallelFolder
{
public AssembliesInParallelFolder(string path)
{
int index = path.LastIndexOf('\\');
this.path = path.Substring(0, index);
var mainAssemlbyDef = AssemblyDefinition.ReadAssembly(path);
assemblyDefinitions = new List<AssemblyDefinition>();
var dllFiles = Directory.GetFiles(this.path, "*.dll", SearchOption.AllDirectories);
foreach (var file in dllFiles)
{
try
{
var assDef = AssemblyDefinition.ReadAssembly(file);
if (assDef.FullName != mainAssemlbyDef.FullName)
{
assemblyDefinitions.Add(assDef);
}
else
{
assDef.Dispose();
}
}
catch
{
}
}
mainAssemlbyDef.Dispose();
}
public string GetAssembly(AssemblyNameReference assemblyNameReference)
{
foreach (var ass in assemblyDefinitions)
{
if (ass.FullName == assemblyNameReference.FullName)
{
return ass.MainModule.FileName;
}
}
return null;
}
private string path;
public List<AssemblyDefinition> assemblyDefinitions;
}
}