private bool IsAssemblyValid() { AssemblyLoadContext assemblyLoadContext = new CollectibleAssemblyLoadContext(); try { Assembly plugin; try { plugin = PluginTester.LoadPlugin(assemblyLoadContext, Model.FileGuid); } catch (Exception e) { Toaster.Error($"Vložený soubor není platná knihovna. ({e.Message})"); return(false); } try { PluginTester.TestImplementation(plugin); } catch (Exception e) { Toaster.Error(e.Message, "Chyba implementace"); return(false); } } finally { assemblyLoadContext.Unload(); } return(true); }
public async Task HandleValidSubmitAsync() { await FileUploadService.UploadAsync(file, Model.FileGuid); var plugin = PluginTester.LoadPlugin(Model.FileGuid); if (plugin == null) { Toaster.Error("Vložený soubor není platná knihovna."); return; } try { PluginTester.TestImplementation(plugin); } catch (Exception e) { Toaster.Error(e.Message, "Chyba implementace"); return; } await PlayerService.InsertNewPlayerAsync(new PlayerVM { Name = Model.Name, Password = Model.Password, FileGuid = Model.FileGuid, League = (League)Convert.ToInt32(Model.League) }); Toaster.Info("Nový hráč vložen."); NavigationManager.NavigateTo("/players"); }