Last active
July 9, 2020 17:06
-
-
Save Craftplacer/ddf4cdc32929ea2a003c852d9e41bcb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Linq; | |
using System.Reflection; | |
namespace BruderMussReflektieren | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
if (args.Length <= 1) | |
{ | |
Console.WriteLine("Brauche schon .NET Assembly und Klassennamen du huan"); | |
return; | |
} | |
var filePath = args[0]; | |
filePath = Path.GetFullPath(filePath); | |
if (!File.Exists(filePath)) | |
{ | |
Console.WriteLine(".NET assembly ned gefunden."); | |
return; | |
} | |
Console.WriteLine($"Lade laufband: {filePath}"); | |
try | |
{ | |
var assembly = Assembly.LoadFile(filePath); | |
var className = args[1]; | |
if (className == null) | |
{ | |
Console.WriteLine("Hurensohn."); | |
return; | |
} | |
className = className.ToLowerInvariant(); | |
var types = assembly.GetTypes(); | |
var found = types.Where(t => t.IsClass && t.BaseType?.ToString().ToLowerInvariant().Contains(className) == true) | |
.OrderBy(t => t.ToString()) | |
.ToArray(); | |
Console.WriteLine($"Habe {found.Length} von {types.Length} gefunden:"); | |
foreach (var type in found) | |
{ | |
Console.ResetColor(); | |
Console.Write($"- {type}"); | |
Console.ForegroundColor = ConsoleColor.DarkGray; | |
Console.WriteLine($" ({type.BaseType})"); | |
} | |
} | |
catch (ReflectionTypeLoadException exFreundin) | |
{ | |
Console.WriteLine(exFreundin); | |
Console.WriteLine("Konnte Assemblür ned laden:"); | |
foreach (var exception in exFreundin.LoaderExceptions) | |
Console.WriteLine(exception.ToString()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment