public Runtime(Type debugMainType = null, params string[] args) { _debugMainType = debugMainType; Config = new Config(args); if (args.Length == 0) { if (Debugging) { Log.Warn(Tr.Get("Runtime.DebugNoMainScript")); } else { var error = Tr.Get("Runtime.NoArgs"); Log.Fatal(error, this); throw new ArgumentException(error, nameof(args)); } } else { try { _mainScript = new FileInfo(args[0]); } catch { } if (_mainScript != null && _mainScript.Exists) { RootPath = _mainScript.Directory; Directory.SetCurrentDirectory(RootPath.FullName); ScriptParser.ParseSetDirectives(_mainScript, (key, value) => Config[key] = value); } else { if (Debugging) { Log.Warn(Tr.Get("Runtime.DebugNoMainScript")); } else { var error = Tr.Get("Runtime.MainScriptMissing", _mainScript?.FullName ?? args[0]); Log.Fatal(error, this); throw new FileNotFoundException(error); } } } if (Config.LogToFile && Log.SetLogFile(new FileInfo(Config.LogFilename), Config.LogAppend)) { Log.ShowConsoleOutput = Config.LogToConsole; } if (Enum.TryParse(Config.ConsoleLogLevel, true, out LogLevels logLevel)) { Log.ConsoleLogLevel = logLevel; } else { Log.Warn(Tr.Get("Runtime.UnknownLogLevel", Config.ConsoleLogLevel)); } if (Enum.TryParse(Config.FileLogLevel, true, out logLevel)) { Log.FileLogLevel = logLevel; } else { Log.Warn(Tr.Get("Runtime.UnknownLogLevel", Config.FileLogLevel)); } Tr.LoadFiles(new DirectoryInfo(Config.TranslationPath)); AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve; AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += AssemblyResolve; var pathList = Config.AssemblyPath.Split(','); foreach (var path in pathList) { var di = new DirectoryInfo(path.Trim()); if (di.Exists) { _assemblyDirectories.Add(di); } } _assemblyDirectories.Add(new DirectoryInfo(Path.GetDirectoryName(MsCoreLib.Location))); var domainAssemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (var assembly in domainAssemblies) { if (assembly != MsCoreLib) { _referencedAssemblies.Add(assembly); } } ReferenceAssembly(GetType().Assembly); ReferenceAssembly(typeof(System.Net.IPNetwork).Assembly); ReferenceAssembly(typeof(YamlDotNet.Core.IEmitter).Assembly); }