public static void Initialize(string assemblyPath) { AppDomainExecutor.Initialize(assemblyPath); DeleteDatabase(); _monitor = AppDomainExecutor.StartAssembly("monitor\\HealthMonitoring.Monitors.SelfHost.exe"); _api = AppDomainExecutor.StartAssembly("api\\HealthMonitoring.SelfHost.exe"); EnsureProcessesAlive(); }
public void Dispose() { if (_restEndpoint != null) { _restEndpoint.Dispose(); _restEndpoint = null; } if (_monitorProcess != null) { AppDomainExecutor.KillAppDomain(_monitorProcess); } }
private void When_monitor_process_with_that_tag_starts() { _monitorProcess = AppDomainExecutor.StartAssembly("monitor2\\HealthMonitoring.Monitors.SelfHost.exe"); }
/// <summary> /// Initialises a new instance of the GridAppDomain with the given AppDomain and AppDomainExecutor /// </summary> /// <param name="domain"></param> /// <param name="executor"></param> internal GridAppDomain(AppDomain domain, AppDomainExecutor executor) { _Domain = domain; _Executor = executor; }
public static void Terminate() { AppDomainExecutor.KillAppDomain(_api); AppDomainExecutor.KillAppDomain(_monitor); }
public static ModBotInstallationState GetModBotInstallationState(string installationPath, out string currentlyInstalledModBotVersion, out string errorMessage) { string assemblyPath = installationPath + "/Clone Drone in the Danger Zone_Data/Managed/Assembly-CSharp.dll"; string modlibraryPath = installationPath + "/Clone Drone in the Danger Zone_Data/Managed/ModLibrary.dll"; if (!File.Exists(assemblyPath)) { throw new Exception("This was not a valid game installation path"); } if (!File.Exists(modlibraryPath)) { currentlyInstalledModBotVersion = null; errorMessage = null; return(ModBotInstallationState.NotInstalled); } // WARNING: This code gets executed in its own AppDomain, so using any variables will not work, you will have to add a field to the GetModBotInstallationInputStateInfo class and use it instead GetModBotInstallationOutputStateInfo state = AppDomainExecutor.Execute(new GetModBotInstallationInputStateInfo() { AssemblyPath = assemblyPath, ModlibraryPath = modlibraryPath, HasDownloadedData = ServerData.HasData, LatestModBotVersion = ServerData.LatestModBotVersion }, delegate(GetModBotInstallationInputStateInfo input) { Assembly assemblyCSharpAssembly; try { assemblyCSharpAssembly = Assembly.LoadFrom(input.AssemblyPath); } catch { return(new GetModBotInstallationOutputStateInfo(ModBotInstallationState.Failed, null, "Could not load one or more required files, if you have Clone Drone running, please close it and try again")); } bool foundModdedObject = false; Type[] types = assemblyCSharpAssembly.GetTypes(); foreach (Type type in types) { if (type.Name == "ModdedObject") { foundModdedObject = true; break; } } if (!foundModdedObject) { return(new GetModBotInstallationOutputStateInfo(ModBotInstallationState.NotInstalled)); } Assembly modlibraryAssembly; try { modlibraryAssembly = Assembly.LoadFrom(input.ModlibraryPath); } catch (IOException io) when((io.HResult & 0x0000FFFF) == 0x000004C8) // ERROR_USER_MAPPED_FILE { return(new GetModBotInstallationOutputStateInfo(ModBotInstallationState.Failed, null, "Could not load one or more required files, if you have Clone Drone running, please close it and try again")); } catch { // If there is an error reading the ModLibrary assembly, we assume the ModBot installation is faulty, so be mark it as not installed return(new GetModBotInstallationOutputStateInfo(ModBotInstallationState.NotInstalled)); } string version = getResurceFromAssembly(modlibraryAssembly, "ModBotVersion"); if (string.IsNullOrEmpty(version)) { return(new GetModBotInstallationOutputStateInfo(ModBotInstallationState.NotInstalled, version)); } if (version.Contains("beta")) { return(new GetModBotInstallationOutputStateInfo(ModBotInstallationState.BetaVersion, version)); } if (!input.HasDownloadedData) { return(new GetModBotInstallationOutputStateInfo(ModBotInstallationState.UnableToVerify, version)); } if (isCloudVersionNewer(version, input.LatestModBotVersion)) { return(new GetModBotInstallationOutputStateInfo(ModBotInstallationState.OutOfDate, version)); } return(new GetModBotInstallationOutputStateInfo(ModBotInstallationState.UpToDate, version)); }); currentlyInstalledModBotVersion = state.ModBotVersion; errorMessage = state.ErrorMessage; return(state.State); }