/
shmachilin
/
MathCore
Обзор
Документация
Войти
/
shmachilin
/
MathCore
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
Tests/ConsoleTest/AppDomainTest.cs
46 строк
1 KB
Павел
Методы-расширения для класса Assembly для представления их в виде графа зависимостей
07 апр 2024, 18:26
07 апр 2024, 18:26
b2e0f87
Код
Авторство
О чём код?
using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime.Loader; using System.Text; using System.Threading.Tasks; namespace ConsoleTest; public static class AppDomainTest { public static void Run() { var context = new AssemblyLoadContext("test", true); context.Unloading += OnUnloading; context.Resolving += OnResolving; var asm = context.LoadFromAssemblyPath(typeof(AppDomainTest).Assembly.Location); var types = asm.GetTypes(); var type = asm.GetType(typeof(DomainEntryPoint).FullName); var result = (string)type.GetMethod(nameof(DomainEntryPoint.Compute)).Invoke(null, [3, 5])!; context.Unload(); } private static Assembly? OnResolving(AssemblyLoadContext context, AssemblyName assembly) { return null; } private static void OnUnloading(AssemblyLoadContext context) { } } internal static class DomainEntryPoint { public static string Compute(int a, int b) => $"{AppDomain.CurrentDomain.FriendlyName}:{a + b}"; }