public bool Run(string[] args) { AppDomainController adc = AppDomainController.Create(ConsoleTitle, new[] { Path.GetDirectoryName(LibPath) }); object ret = adc.LoadTypeAndRunFunction(LibPath, TypeSignature, "Run", new object[] { args }); adc.Dispose(); return(ret == null || ret is bool b && b); }
public bool CheckConsoles() { bool changed = false; List <string> allFiles = Directory .GetFiles(ConsolePaths.AssemblyPath, "*Console.*", SearchOption.AllDirectories) .Select(x => x.Replace("\\", "/")).ToList(); string[] removedFiles = FindRemovedFiles(allFiles.ToArray()); for (int i = ConsoleEntries.Count - 1; i >= 0; i--) { if (removedFiles.Contains(ConsoleEntries[i].LibPath)) { changed = true; Console.WriteLine("Removing Missing Console: " + ConsoleEntries[i].ConsoleTitle); ConsoleEntries.RemoveAt(i); } } string[] changedFiles = FindChangedFiles(allFiles.ToArray()); if (changedFiles.Length != 0) { changed = true; ConsoleEntries.Clear(); } string[] addedFiles = FindAddedFiles(allFiles.ToArray()); for (int i = 0; i < addedFiles.Length; i++) { string ext = Path.GetExtension(addedFiles[i]); if (!ConsoleRunner.Resolvers.ContainsKey(ext)) { Console.WriteLine("Can not find Resolver for Extension: " + ext); continue; } string libPath = ConsoleRunner.Resolvers[ext] .ResolveLibrary(addedFiles[i]); changed = true; AppDomainController adc = AppDomainController.Create("LoadingAssembly_" + libPath, new[] { Path.GetDirectoryName(libPath) }); try { Type[] consoleTypes = adc.GetTypes(libPath, typeof(AConsole)); foreach (Type consoleType in consoleTypes) { ConsoleItem console = new ConsoleItem(adc, libPath, consoleType); Console.WriteLine("Adding New Console: " + console.ConsoleTitle); ConsoleEntries.Add(console); } adc.Dispose(); } catch (Exception e) { adc.Dispose(); throw e; } } return(changed); }