-
Notifications
You must be signed in to change notification settings - Fork 2
/
Extensions.cs
42 lines (39 loc) · 1.08 KB
/
Extensions.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
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace UsageRateTool
{
static class Extensions
{
public static string GetFullName(this MemberInfo mi)
{
return $"{mi?.DeclaringType?.Namespace}.{mi.DeclaringType?.Name}.{mi.Name}";
}
public static string ToByteString(this byte[] bytes)
{
StringBuilder sb = new StringBuilder();
foreach (var b in bytes)
{
sb.Append($"{b:x}:");
}
sb.Remove(sb.Length - 1, 1);
return sb.ToString();
}
public static MethodBase ResolveMethod(this IEnumerable<Module> modules, int metadataToken)
{
foreach (var module in modules)
{
try
{
return module.ResolveMethod(metadataToken);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
return null;
}
}
}