private static void FillActions() { //Получим сборку var checkModulePath = Path.Combine(ModuleGovernor.GetPathToModule(GetComponentName()), "bin", "Debug", "netcoreapp3.1", $"ALS.CheckModule.Component.{GetComponentName()}.dll"); var checkModuleAssembly = _manager.Execute(out _weakReference, out _loadContext, checkModulePath); //Получим все действия пользователя var checkersAvailable = checkModuleAssembly.GetTypes().Where(t => t.IsClass && typeof(T).IsAssignableFrom(t)); //Соберем(или обновим) словарь действий foreach (var action in checkersAvailable) { if (!Actions.ContainsKey(action.Name)) { Actions.Add(action.Name, (T)Activator.CreateInstance(action)); } } }
public async Task <bool> ReloadActions() { if (Actions.Count != 0) { Actions.Clear(); await _manager.Unload(_weakReference, _loadContext); } var result = await ModuleGovernor.BuildModule(GetComponentName()); ModuleGovernor.AllowBuild(); if (result) { _loadContext = new CheckModuleLoadContext(); FillActions(); } return(result); }