private static string[] LoadAppNames(PROBEENVSRVRLib.ProbeEnv env) { var list = new List <string>(); var e = env.EnumApps(); // One-based array for (int i = 1, ii = e.Count; i <= ii; i++) { list.Add(e.Element(i).Name); } return(list.ToArray()); }
private static ProbeAppSettings ReloadCurrentApp(string appName = "") { Log.Write(LogLevel.Info, "Loading application settings..."); var startTime = DateTime.Now; var appSettings = new ProbeAppSettings(); PROBEENVSRVRLib.ProbeEnv env = null; PROBEENVSRVRLib.ProbeEnvApp currentApp = null; try { env = new PROBEENVSRVRLib.ProbeEnv(); if (!string.IsNullOrEmpty(appName)) { currentApp = env.FindApp(appName); } if (currentApp == null) { currentApp = env.FindApp(env.DefaultAppName); } if (currentApp == null) { Debug.WriteLine("No current app found."); appSettings.Initialized = true; } else { Debug.WriteLine("Current App: " + currentApp.Name); appSettings.AppName = currentApp.Name; appSettings.Initialized = true; appSettings.PlatformPath = (env as PROBEENVSRVRLib.IProbeEnvPlatform).Folder; appSettings.AllAppNames = LoadAppNames(env); appSettings.SourceDirs = LoadSourceDirs(currentApp); appSettings.IncludeDirs = LoadIncludeDirs(currentApp, appSettings); appSettings.LibDirs = LoadLibDirs(currentApp, appSettings); appSettings.ExeDirs = LoadExeDirs(currentApp); appSettings.ObjectDir = currentApp.ObjectPath; appSettings.TempDir = currentApp.TempPath; appSettings.ReportDir = currentApp.ListingsPath; appSettings.DataDir = currentApp.DataPath; appSettings.LogDir = currentApp.LogPath; appSettings.SourceFiles = LoadSourceFiles(appSettings); appSettings.IncludeFiles = LoadIncludeFiles(appSettings); } var elapsed = DateTime.Now.Subtract(startTime); Log.Write(LogLevel.Info, "Application settings reloaded (elapsed: {0})", elapsed); return(appSettings); } finally { if (currentApp != null) { Marshal.ReleaseComObject(currentApp); currentApp = null; } if (env != null) { Marshal.ReleaseComObject(env); env = null; } } }