public void TestFileInputEqualsOutput() { string testFile = @"C:\Users\mtr\Source\Repos\GardanZero\HS_VNFrame_ScriptHelper\HS_VNFrame_ScriptHelper\Scripts\fun2"; LoaderForm loaderForm = new LoaderForm(); loaderForm.StructureLoader = new StructureLoader(testFile + ".py", loaderForm); loaderForm.StructureLoader.LoadStructure(); loaderForm.SaveFile(testFile + "_unitTest.py"); string origFileText = File.ReadAllText(testFile + ".py"); string testFileText = File.ReadAllText(testFile + "_unitTest.py"); if (origFileText == testFileText) { Assert.AreEqual(origFileText, testFileText); } else { Assert.Fail("The input and output file text does not match."); } // cleanup File.Delete(testFile + "_unitTest.py"); }
public static bool Initialize() { var loadfrm = new LoaderForm(); loadfrm.Show(); loadfrm.Refresh(); foreach (var i in GlobalVar.DIRDICT) { loadfrm.Render("Directory Check...\n" + i); MKDIR(i.Value); } WebClient wc = new WebClient(); if (!File.Exists(GlobalVar.DIRDICT["BINDIR"] + "\\nuget.exe")) { wc.DownloadFile(GlobalVar.NUGET, GlobalVar.DIRDICT["BINDIR"] + "\\nuget.exe"); } else { FileInfo fi = new FileInfo(GlobalVar.DIRDICT["BINDIR"] + "\\nuget.exe"); if (fi.Length < 1024) { wc.DownloadFile(GlobalVar.NUGET, GlobalVar.DIRDICT["BINDIR"] + "\\nuget.exe"); } } loadfrm.Render("Get Nuget Package...\n"); var nupkgs = new List <string>() { "install cefsharp.winforms -version " + GlobalVar.TargetCEFTAG, "install cefsharp.offscreen -version " + GlobalVar.TargetCEFTAG, "install newtonsoft.json -version 10.0.3", }; foreach (var bin in nupkgs) { loadfrm.Render(bin); var p = new Process() { StartInfo = new ProcessStartInfo() { WorkingDirectory = GlobalVar.DIRDICT["BINDIR"], WindowStyle = ProcessWindowStyle.Hidden, Arguments = bin, CreateNoWindow = true, FileName = GlobalVar.DIRDICT["BINDIR"] + "\\nuget.exe" } }; p.Start(); while (!p.HasExited) { Thread.Sleep(100); } } loadfrm.Render("Arrange Nuget Package...\n"); var dirs = new List <string>() { "cef.redist.x64." + GlobalVar.TargetCEFVER + "\\CEF", "cef.redist.x86." + GlobalVar.TargetCEFVER + "\\CEF", "cef.redist.x64." + GlobalVar.TargetCEFVER + "\\CEF\\locales", "cef.redist.x86." + GlobalVar.TargetCEFVER + "\\CEF\\locales", "cef.redist.x64." + GlobalVar.TargetCEFVER + "\\CEF\\swiftshader", "cef.redist.x86." + GlobalVar.TargetCEFVER + "\\CEF\\swiftshader", "CefSharp.Common." + GlobalVar.TargetCEFTAG + "\\CefSharp\\x86", "CefSharp.Common." + GlobalVar.TargetCEFTAG + "\\CefSharp\\x64", "CefSharp.OffScreen." + GlobalVar.TargetCEFTAG + "\\CefSharp\\x86", "CefSharp.OffScreen." + GlobalVar.TargetCEFTAG + "\\CefSharp\\x64", "CefSharp.WinForms." + GlobalVar.TargetCEFTAG + "\\CefSharp\\x86", "CefSharp.WinForms." + GlobalVar.TargetCEFTAG + "\\CefSharp\\x64", }; foreach (var d in dirs) { var bin = Path.Combine(GlobalVar.DIRDICT["BINDIR"], d); var x = "x86"; var dest = ""; if (d.Contains("x64")) { x = "x64"; } if (d.Contains("cef.redist")) { dest = Path.Combine(GlobalVar.DIRDICT["CEFDIR"], x, d // <- for once working -> .Replace("cef.redist.x86." + GlobalVar.TargetCEFVER + "\\CEF", "") .Replace("cef.redist.x64." + GlobalVar.TargetCEFVER + "\\CEF", "") .Replace("\\", "")); } else { dest = Path.Combine(GlobalVar.DIRDICT["CEFDIR"], x); } foreach (var file in Directory.GetFiles(bin)) { if (file.Contains(".pdb")) { continue; } var f = Path.Combine(dest, Path.GetFileName(file)); if (!File.Exists(f)) { File.Copy(file, f); } } } foreach (var i in Directory.GetFiles(Environment.CurrentDirectory)) { if (i.Contains("cefsharp")) { File.Delete(i); } } loadfrm.Render("Initializing..."); Thread.Sleep(500); if (!loadfrm.IsDisposed) { loadfrm.Dispose(); } if (Program.fromMain) // run to exe { Overlays.Loader.InitializeMinimum(); Application.Run(new Overlays.OverlayManager.ManagerForm()); } else { } return(true); }
static void Main() { var args = Environment.GetCommandLineArgs(); if (GetCommandLineSwitch("/?", args) || GetCommandLineSwitch("/h", args) || GetCommandLineSwitch("/help", args)) { PrintCommandLineParameters(); Environment.Exit(0); return; } var logFile = GetCommandLineParameter("/log", args); if (logFile != null) { try { Logger.Out = File.CreateText(logFile); } catch (Exception e) { Logger.LogWarn(e, "Unable to open log file at '{0}'", logFile); } } #if DEBUG Logger.LogLevel = 5; #endif if (int.TryParse(GetCommandLineParameter("/loglevel", args), NumberStyles.Any, null, out var logLevel)) { Logger.LogLevel = logLevel; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.VisualStyleState = VisualStyleState.ClientAndNonClientAreasEnabled; Application.ThreadException += ApplicationThreadException; Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException; AppDomain.CurrentDomain.FirstChanceException += CurrentDomainFirstChanceException; ThreadPool.SetMaxThreads(50, 200); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; // Permit unmanaged code permissions new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert(); DisableExceptionReporter = GetCommandLineSwitch("/DisableExceptionReporter", args); #if DEBUG System.Windows.Forms.Timer watchdogTimer; #endif bool mutexAquired = false; using (var mutex = new Mutex(false, GlobalMutexId)) { Logger.LogNotice($"ContactPoint IP Phone version: {typeof(Program).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion}"); Logger.LogNotice($"Main Thread Culture is '{Thread.CurrentThread.CurrentCulture}'"); Logger.LogNotice($"UI Thread Culture is '{Thread.CurrentThread.CurrentUICulture}'"); #if DEBUG if (args.Contains("/debugger", StringComparer.InvariantCultureIgnoreCase)) { if (Debugger.IsAttached) { Debugger.Break(); } else { Debugger.Launch(); } } #endif #if DEBUG watchdogTimer = new System.Windows.Forms.Timer { Interval = 3000 }; watchdogTimer.Tick += (s, e) => { _watcherLastActivity = DateTime.Now; }; watchdogTimer.Start(); _watcherTargetThread = Thread.CurrentThread; _watcherLastActivity = DateTime.Now; ThreadPool.QueueUserWorkItem(WatcherThreadFunc); #endif var makeCallMessage = StartPhoneCallCommand.CreateFromCommandLine(GetCommandLineParameter("/call", args)); try { try { if (!WaitForMutex(mutex)) { SharedFileMessageTransportHost.SendMessage(makeCallMessage); Environment.Exit(0); return; } else { mutexAquired = true; } } catch (Exception e) { Logger.LogError(e); Environment.Exit(-1); } using (AppContext = new MainFormApplicationContext()) { if (!GetCommandLineSwitch("/DisableSplashScreen", args)) { LoaderForm = new LoaderForm(); ThreadPool.QueueUserWorkItem(ShowSplashScreen); } CoreLoader.LoadingFailed += LoadingFailed; CoreLoader.PartLoading += PartLoading; foreach (var assembly in typeof(Program).Assembly.GetReferencedAssemblies()) { PartLoading($"Load dependency: {assembly.Name} v{assembly.Version}"); AppDomain.CurrentDomain.Load(assembly); } PartLoading("Initialize Exception Reporter"); ExceptionReporter = new ExceptionReporter.ExceptionReporter(); ExceptionReporter.Config.ShowFlatButtons = false; ExceptionReporter.Config.ShowLessMoreDetailButton = true; ExceptionReporter.Config.CompanyName = "ContactPoint"; ExceptionReporter.Config.ContactEmail = "*****@*****.**"; ExceptionReporter.Config.WebUrl = "http://www.contactpoint.com.ua/"; #if DEBUG ExceptionReporter.Config.ShowFullDetail = true; #else ExceptionReporter.Config.ShowFullDetail = false; #endif // Create WPF application in order to let WPF controls work correctly PartLoading("Initialize WPF Infrastructure"); System.Windows.Application wpfApp = null; Window wpfWnd = null; try { PartLoading("Create WPF Application"); wpfApp = new System.Windows.Application(); PartLoading("Create WPF Window"); wpfWnd = new Window { Visibility = Visibility.Hidden, ShowInTaskbar = false, Width = 1, Height = 1 }; PartLoading("Core infrastructure"); using (var core = CoreLoader.CreateCore(AppContext.MainForm)) { PartLoading("Audio services"); using (new AudioDeviceService(core)) { #if DEBUG if (args.Contains("/newui")) { new PhoneWindow().Show(); } #endif PartLoading("Configuring WinForms Infrastructure"); AppContext.ContactPointForm.Core = core; AppContext.ContactPointForm.CallOnStartup = makeCallMessage; AppContext.ContactPointForm.DisableSettingsFormAutoStartup = GetCommandLineSwitch("/DisableSettingsFormAutoStartup", args); AppContext.ContactPointForm.Shown += MainFormShown; PartLoading("Starting WinForms UI"); Application.Run(AppContext); } } } finally { wpfWnd?.Close(); wpfApp?.Shutdown(0); } } } finally { if (mutexAquired) { mutex.ReleaseMutex(); } #if DEBUG _watcherThreadShutdown = true; watchdogTimer.Stop(); #endif } } }