Beispiel #1
0
    /// <summary>
    /// Main entry point.
    /// </summary>
    private static async Task Main(string[] args)
    {
        var argsProcessor = new ArgsProcessor(args);

        // For now this is enough. If you run it on macOS you want to sign.
        if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
        {
            MacSignTools.Sign(argsProcessor);
            return;
        }

        // Only binaries mode is for deterministic builds.
        OnlyBinaries = argsProcessor.IsOnlyBinariesMode();

        IsContinuousDelivery = argsProcessor.IsContinuousDeliveryMode();

        ReportStatus();

        if (argsProcessor.IsPublish() || IsContinuousDelivery || OnlyBinaries)
        {
            await PublishAsync().ConfigureAwait(false);

            IoHelpers.OpenFolderInFileExplorer(BinDistDirectory);
        }

        if (argsProcessor.IsSign())
        {
            await SignAsync().ConfigureAwait(false);
        }
    }
Beispiel #2
0
        public static void Main(string[] args)
        {
            DisplayIntroductionMessages();

            ApplicationMode applicationMode;

            if (!ArgsProcessor.TryGetApplicationMode(args, out applicationMode, out string errorMessage))
            {
                Console.WriteLine(errorMessage);
                Console.WriteLine("Press enter to quit");
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine($"Starting in mode:  {applicationMode.ToName()}  ");
                Console.WriteLine(String.Empty);

                //TODO: Remove all of TEST mode. Only for debug
                if (applicationMode == ApplicationMode.TEST)
                {
                    var application = new Startup(applicationMode);
                    application.ProduceFakeTestMessage();
                }
                else
                {
                    var application = new Startup(applicationMode);
                    application.Start();
                }
                Console.ReadLine();
            }
        }
        internal static List <IReportCreator> CreateReporters(ArgsProcessor argProc)
        {
            var reporters = new List <IReportCreator> {
                new ConsoleReportCreator(), new HtmlReportCreator(argProc)
            };

            return(reporters);
        }
Beispiel #4
0
        private static void SampleTwo(string[] args)
        {
            var argThings = new ArgsActions();

            argThings.SetOption("-a", () => Console.WriteLine("-a option selected"));
            argThings.SetOption("-e", () => Console.WriteLine("-e option selected"));

            var processor = new ArgsProcessor(argThings);

            processor.Process(args);
        }
Beispiel #5
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //Only if user has chosen to generate log
            var debugMode = Environment.GetEnvironmentVariable("XDM_DEBUG_MODE");

            if (!string.IsNullOrEmpty(debugMode) && debugMode == "1")
            {
                var logFile = Path.Combine(Config.DataDir, "log.txt");
                Log.InitFileBasedTrace(Path.Combine(Config.DataDir, "log.txt"));
            }
            Log.Debug($"Application_Startup::args->: {string.Join(" ", Environment.GetCommandLineArgs())}");

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            core = new ApplicationCore();
            win  = new MainWindow();
            app  = new XDMApp();

            ApplicationContext.Configurer()
            .RegisterApplicationWindow(win)
            .RegisterApplication(app)
            .RegisterApplicationCore(core)
            .RegisterCapturedVideoTracker(new VideoTracker())
            .RegisterClipboardMonitor(new ClipboardMonitor())
            .RegisterLinkRefresher(new LinkRefresher())
            .RegisterPlatformUIService(new WpfPlatformUIService())
            .Configure();

            var args           = Environment.GetCommandLineArgs();
            var commandOptions = ArgsProcessor.ParseArgs(args, 1);

            AppTrayIcon.AttachToSystemTray();
            AppTrayIcon.TrayClick += (_, _) =>
            {
                win.Show();
                if (win.WindowState == WindowState.Minimized)
                {
                    win.WindowState = WindowState.Normal;
                }
                win.Activate();
            };

            if (!commandOptions.ContainsKey("-m"))
            {
                win.Show();
                if (commandOptions.ContainsKey("-i"))
                {
                    Config.Instance.RunOnLogon = true;
                    Config.SaveConfig();
                    ApplicationContext.PlatformUIService.ShowBrowserMonitoringDialog();
                }
            }
        }
Beispiel #6
0
        public static void  Test()
        {
            //实际上就是一种表驱动编程方法的实践
            Console.WriteLine("【委托的使用,字典的使用,以及[,]多维操作符的自定义】");
            ArgsActions aas = new ArgsActions();
            DoAction    da  = new DoAction();
            Action      a1  = da.PrintAdd;
            Action      a2  = da.PrintMod;

            aas.SetOption("add", a1);
            aas.SetOption("mod", a2);
            ArgsProcessor ap = new ArgsProcessor(aas);

            ap.Process(new string[] { "add", "mod" });
        }
        internal void CreateReport(ArgsProcessor argProc)
        {
            _argProc = argProc;
            var dirManager = new DirectoryManager(argProc);

            _combinedPersist = new CombinedReportPersistance(dirManager);

            var combined = _combinedPersist.LoadCombinedData();

            var template = new TemplateCreator(argProc, TemplateCreator.TemplateNameCombinedReport);

            SetHeader(combined, template);

            string suitesHtml = GetSuitesHtml(combined.ReportSets);

            template.SetTemplateParam(TemplateCreator.TemplateParamCombinedSuiteParts, suitesHtml);

            var outPath = dirManager.GetCombinedReportHtmlPath();

            template.Save(outPath);
        }
Beispiel #8
0
    /// <summary>
    /// Main entry point.
    /// </summary>
    private static async Task Main(string[] args)
    {
        var argsProcessor = new ArgsProcessor(args);

        // For now this is enough. If you run it on macOS you want to sign.
        if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
        {
            MacSignTools.Sign();
            return;
        }

        // Only binaries mode is for deterministic builds.
        OnlyBinaries = argsProcessor.IsOnlyBinariesMode();

        IsContinuousDelivery = argsProcessor.IsContinuousDeliveryMode();

        ReportStatus();

        if (DoPublish || OnlyBinaries)
        {
            await PublishAsync().ConfigureAwait(false);

            IoHelpers.OpenFolderInFileExplorer(BinDistDirectory);
        }

#pragma warning disable CS0162 // Unreachable code detected
        if (!OnlyBinaries)
        {
            if (DoSign)
            {
                await SignAsync().ConfigureAwait(false);
            }

            if (DoRestoreProgramCs)
            {
                RestoreProgramCs();
            }
        }
#pragma warning restore CS0162 // Unreachable code detected
    }
Beispiel #9
0
        /// <summary>
        /// Populates the controls from scratch
        /// </summary>
        private void PopulateControls()
        {
            this.snippets = new Dictionary <String, String[]>();
            this.ListSnippetFolders();
            this.UpdateSnippetList();
            this.PopulateInsertComboBox();
            Boolean foundSyntax = false;
            String  curSyntax   = ArgsProcessor.GetCurSyntax();

            foreach (Object item in this.languageDropDown.Items)
            {
                if (item.ToString().ToLower() == curSyntax)
                {
                    this.languageDropDown.SelectedItem = item;
                    foundSyntax = true;
                    break;
                }
            }
            if (!foundSyntax && this.languageDropDown.Items.Count > 0)
            {
                this.languageDropDown.SelectedIndex = 0;
            }
            this.columnHeader.Width = -2;
        }
Beispiel #10
0
 public HtmlReportCreator(ArgsProcessor argProc)
 {
     _argProc = argProc;
 }
Beispiel #11
0
        public void IsOnlyBinariesModeTest(string[] input, bool expectedResult)
        {
            var argsProcessor = new ArgsProcessor(input);

            Assert.Equal(expectedResult, argsProcessor.IsOnlyBinariesMode());
        }
Beispiel #12
0
    public static void Sign(ArgsProcessor argsProcessor)
    {
        if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
        {
            throw new NotSupportedException("This signing method is only valid on macOS!");
        }

        Console.WriteLine("Phase: finding the zip file on desktop which contains the compiled binaries from Windows.");

        string desktopPath          = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
        string removableDriveFolder = Tools.GetSingleUsbDrive();

        var srcZipFileNamePattern = "WasabiToNotarize-*";
        var files = Directory.GetFiles(removableDriveFolder, srcZipFileNamePattern);

        if (files.Length != 2)
        {
            throw new InvalidDataException($"{srcZipFileNamePattern} file missing or there are more! There must be exactly two!");
        }

        var(appleId, password) = argsProcessor.GetAppleIdAndPassword();

        while (string.IsNullOrWhiteSpace(appleId))
        {
            Console.WriteLine("Enter appleId (email):");
            appleId = Console.ReadLine();
        }

        while (string.IsNullOrWhiteSpace(password))
        {
            Console.WriteLine("Enter password:"******"WasabiToNotarize-2.0.0.0-arm64.zip or WasabiToNotarize-2.0.0.0.zip ".
            var workingDir          = Path.Combine(desktopPath, "wasabiTemp");
            var dmgPath             = Path.Combine(workingDir, "dmg");
            var unzippedPath        = Path.Combine(workingDir, "unzipped");
            var appName             = $"{Constants.AppName}.app";
            var appPath             = Path.Combine(dmgPath, appName);
            var appContentsPath     = Path.Combine(appPath, "Contents");
            var appMacOsPath        = Path.Combine(appContentsPath, "MacOS");
            var appResPath          = Path.Combine(appContentsPath, "Resources");
            var appFrameworksPath   = Path.Combine(appContentsPath, "Frameworks");
            var infoFilePath        = Path.Combine(appContentsPath, "Info.plist");
            var dmgFileName         = zipFile.Replace("WasabiToNotarize", "Wasabi").Replace("zip", "dmg");
            var dmgFilePath         = Path.Combine(workingDir, dmgFileName);
            var dmgUnzippedFilePath = Path.Combine(workingDir, $"Wasabi.tmp.dmg");
            var appNotarizeFilePath = Path.Combine(workingDir, $"Wasabi-{versionPrefix}.zip");
            var contentsPath        = Path.GetFullPath(Path.Combine(Program.PackagerProjectDirectory.Replace("\\", "//"), "Content", "Osx"));
            var entitlementsPath    = Path.Combine(contentsPath, "entitlements.plist");
            var dmgContentsDir      = Path.Combine(contentsPath, "Dmg");
            var desktopDmgFilePath  = Path.Combine(desktopPath, dmgFileName);

            var signArguments = $"--sign \"L233B2JQ68\" --verbose --force --options runtime --timestamp";

            Console.WriteLine("Phase: creating the working directory.");

            if (Directory.Exists(workingDir))
            {
                DeleteWithChmod(workingDir);
            }

            if (File.Exists(desktopDmgFilePath))
            {
                File.Delete(desktopDmgFilePath);
            }

            Console.WriteLine("Phase: creating the app.");

            IoHelpers.EnsureDirectoryExists(appResPath);
            IoHelpers.EnsureDirectoryExists(appMacOsPath);

            ZipFile.ExtractToDirectory(zipPath, appMacOsPath);             // Copy the binaries.

            IoHelpers.CopyFilesRecursively(new DirectoryInfo(Path.Combine(contentsPath, "App")), new DirectoryInfo(appPath));

            Console.WriteLine("Update the plist file with current information for example with version.");

            var    lines            = File.ReadAllLines(infoFilePath);
            string?bundleIdentifier = null;

            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];
                if (!line.TrimStart().StartsWith("<key>", StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                if (line.Contains("CFBundleShortVersionString", StringComparison.InvariantCulture) ||
                    line.Contains("CFBundleVersion", StringComparison.InvariantCulture))
                {
                    lines[i + 1] = lines[i + 1].Replace("?", $"{Version.Parse(versionPrefix).ToString(3)}");                     // Apple allow only 3 version tags in plist.
                }
                else if (line.Contains("CFBundleIdentifier", StringComparison.InvariantCulture))
                {
                    bundleIdentifier = lines[i + 1].Trim().Replace("<string>", "").Replace("</string>", "");
                }
            }
            if (string.IsNullOrWhiteSpace(bundleIdentifier))
            {
                throw new InvalidDataException("Bundle identifier not found in plist file.");
            }

            File.Delete(infoFilePath);

            File.WriteAllLines(infoFilePath, lines);

            using (var process = Process.Start(new ProcessStartInfo
            {
                FileName = "chmod",
                Arguments = $"-R u+rwX,go+rX,go-w \"{appPath}\"",
                WorkingDirectory = workingDir
            }))
            {
                WaitProcessToFinish(process, "chmod");
            }

            var filesToCheck = new[] { entitlementsPath };

            foreach (var file in filesToCheck)
            {
                if (!File.Exists(file))
                {
                    throw new FileNotFoundException($"File missing: {file}");
                }
            }

            Console.WriteLine("Signing the files in app.");

            IoHelpers.EnsureDirectoryExists(appResPath);
            IoHelpers.EnsureDirectoryExists(appMacOsPath);

            var executables = GetExecutables(appPath);

            // The main executable needs to be signed last.
            var filesToSignInOrder = Directory.GetFiles(appPath, "*.*", SearchOption.AllDirectories)
                                     .OrderBy(file => executables.Contains(file))
                                     .OrderBy(file => new FileInfo(file).Name == "wassabee")
                                     .ToArray();

            foreach (var file in executables)
            {
                using var process = Process.Start(new ProcessStartInfo
                {
                    FileName         = "chmod",
                    Arguments        = $"u+x \"{file}\"",
                    WorkingDirectory = workingDir
                });
                WaitProcessToFinish(process, "chmod");
            }

            SignDirectory(filesToSignInOrder, workingDir, signArguments, entitlementsPath);

            Console.WriteLine("Phase: verifying the signature.");

            Verify(appPath);

            Console.WriteLine("Phase: notarize the app.");

            // Source: https://blog.frostwire.com/2019/08/27/apple-notarization-the-signature-of-the-binary-is-invalid-one-other-reason-not-explained-in-apple-developer-documentation/
            using (var process = Process.Start(new ProcessStartInfo
            {
                FileName = "ditto",
                Arguments = $"-c -k --keepParent \"{appPath}\" \"{appNotarizeFilePath}\"",
                WorkingDirectory = workingDir
            }))
            {
                WaitProcessToFinish(process, "ditto");
            }

            Notarize(appleId, password, appNotarizeFilePath, bundleIdentifier);
            Staple(appPath);

            using (var process = Process.Start(new ProcessStartInfo
            {
                FileName = "spctl",
                Arguments = $"-a -t exec -vv \"{appPath}\"",
                WorkingDirectory = workingDir,
                RedirectStandardError = true
            }))
            {
                var    nonNullProcess = WaitProcessToFinish(process, "spctl");
                string result         = nonNullProcess.StandardError.ReadToEnd();
                if (!result.Contains(": accepted"))
                {
                    throw new InvalidOperationException(result);
                }
            }

            Console.WriteLine("Phase: creating the dmg.");

            if (File.Exists(dmgFilePath))
            {
                File.Delete(dmgFilePath);
            }

            Console.WriteLine("Phase: creating dmg.");

            IoHelpers.CopyFilesRecursively(new DirectoryInfo(dmgContentsDir), new DirectoryInfo(dmgPath));

            File.Copy(Path.Combine(contentsPath, "WasabiLogo.icns"), Path.Combine(dmgPath, ".VolumeIcon.icns"), true);

            var temp = Path.Combine(dmgPath, ".DS_Store.dat");
            File.Move(temp, Path.Combine(dmgPath, ".DS_Store"), true);

            using (var process = Process.Start(new ProcessStartInfo
            {
                FileName = "ln",
                Arguments = "-s /Applications",
                WorkingDirectory = dmgPath
            }))
            {
                WaitProcessToFinish(process, "ln");
            }

            var hdutilCreateArgs = string.Join(
                " ",
                new string[]
            {
                "create",
                $"\"{dmgUnzippedFilePath}\"",
                "-ov",
                $"-volname \"Wasabi Wallet\"",
                "-fs HFS+",
                $"-srcfolder \"{dmgPath}\""
            });

            using (var process = Process.Start(new ProcessStartInfo
            {
                FileName = "hdiutil",
                Arguments = hdutilCreateArgs,
                WorkingDirectory = dmgPath
            }))
            {
                WaitProcessToFinish(process, "hdiutil");
            }

            var hdutilConvertArgs = string.Join(
                " ",
                new string[]
            {
                "convert",
                $"\"{dmgUnzippedFilePath}\"",
                "-format UDZO",
                $"-o \"{dmgFilePath}\""
            });

            using (var process = Process.Start(new ProcessStartInfo
            {
                FileName = "hdiutil",
                Arguments = hdutilConvertArgs,
                WorkingDirectory = dmgPath
            }))
            {
                WaitProcessToFinish(process, "hdiutil");
            }

            Console.WriteLine("Phase: signing the dmg file.");

            SignFile($"{signArguments} --entitlements \"{entitlementsPath}\" \"{dmgFilePath}\"", dmgPath);

            Console.WriteLine("Phase: verifying the signature.");

            Verify(dmgFilePath);

            Console.WriteLine("Phase: notarize dmg");
            Notarize(appleId, password, dmgFilePath, bundleIdentifier);

            Console.WriteLine("Phase: staple dmp");
            Staple(dmgFilePath);

            using (var process = Process.Start(new ProcessStartInfo
            {
                FileName = "spctl",
                Arguments = $"-a -t open --context context:primary-signature -v \"{dmgFilePath}\"",
                WorkingDirectory = workingDir,
                RedirectStandardError = true
            }))
            {
                var    nonNullProcess = WaitProcessToFinish(process, "spctl");
                string result         = nonNullProcess.StandardError.ReadToEnd();
                if (!result.Contains(": accepted"))
                {
                    throw new InvalidOperationException(result);
                }
            }

            File.Move(dmgFilePath, desktopDmgFilePath);
            DeleteWithChmod(workingDir);

            Console.WriteLine("Phase: finish.");

            var toRemovableFilePath = Path.Combine(removableDriveFolder, Path.GetFileName(desktopDmgFilePath));
            File.Move(desktopDmgFilePath, toRemovableFilePath, true);

            if (File.Exists(zipPath))
            {
                File.Delete(zipPath);
            }
        }
    }
Beispiel #13
0
 public TemplateCreator(ArgsProcessor argProc, string templateName)
 {
     this._argProc = argProc;
     _templateHtml = ReadHtmlFromTemplate(templateName);
 }
Beispiel #14
0
 internal CustomImageComparer(ArgsProcessor argProc)
 {
     _argProc = argProc;
 }
Beispiel #15
0
        internal static void Handle(RawBrowserMessageEnvelop envelop)
        {
            //Log.Debug("Type: " + envelop.MessageType);
            if (envelop.MessageType == "videoIds")
            {
                foreach (var item in envelop.VideoIds)
                {
                    ApplicationContext.VideoTracker.AddVideoDownload(item);
                }
                return;
            }

            if (envelop.MessageType == "clear")
            {
                ApplicationContext.VideoTracker.ClearVideoList();
                return;
            }

            if (envelop.MessageType == "sync")
            {
                return;
            }

            if (envelop.MessageType == "custom")
            {
                var args = ArgsProcessor.ParseArgs(envelop.CustomData.Split('\r'));
                ArgsProcessor.Process(args);
                return;
            }

            var rawMessage = envelop.Message;

            if (rawMessage == null && envelop.Messages == null)
            {
                Log.Debug("Raw message/messages is null");
                return;
            }
            ;

            switch (envelop.MessageType)
            {
            case "download":
            {
                var message = Parse(rawMessage);
                if (!(Helpers.IsBlockedHost(message.Url) || Helpers.IsCompressedJSorCSS(message.Url)))
                {
                    ApplicationContext.CoreService.AddDownload(message);
                }
                break;
            }

            case "links":
            {
                var messages = new List <Message>(envelop.Messages.Length);
                foreach (var msg in envelop.Messages)
                {
                    var message = Parse(msg);
                    messages.Add(message);
                }
                ApplicationContext.CoreService.AddBatchLinks(messages);
                break;
            }

            case "video":
            {
                var message     = Parse(rawMessage);
                var contentType = message.GetResponseHeaderFirstValue("Content-Type");

                if (VideoUrlHelper.IsYtFormat(contentType))
                {
                    VideoUrlHelper.ProcessPostYtFormats(message);
                }

                //if (VideoUrlHelper.IsFBFormat(contentType, message.Url))
                //{
                //    VideoUrlHelper.ProcessPostFBFormats(message, ApplicationContext.Core);
                //}

                if (VideoUrlHelper.IsHLS(contentType))
                {
                    VideoUrlHelper.ProcessHLSVideo(message);
                }

                if (VideoUrlHelper.IsDASH(contentType))
                {
                    VideoUrlHelper.ProcessDashVideo(message);
                }

                if (!VideoUrlHelper.ProcessYtDashSegment(message))
                {
                    if (VideoUrlHelper.IsNormalVideo(contentType, message.Url, message.GetContentLength()))
                    {
                        VideoUrlHelper.ProcessNormalVideo(message);
                    }
                }
                break;
            }
            }
        }
Beispiel #16
0
        static void Main(string[] args)
        {
            Gtk.Application.Init();
            GLib.ExceptionManager.UnhandledException += ExceptionManager_UnhandledException;
            var globalStyleSheet = @"
                                    .large-font{ font-size: 16px; }
                                    .medium-font{ font-size: 14px; }
                                    ";

            var screen   = Gdk.Screen.Default;
            var provider = new CssProvider();

            provider.LoadFromData(globalStyleSheet);
            Gtk.StyleContext.AddProviderForScreen(screen, provider, 800);
            //var screen = Gdk.Screen.Default;
            //var provider = new CssProvider();
            //provider.LoadFromData(@".dark
            //                                    {
            //                                        color: gray;
            //                                        background: rgb(36,41,46);
            //                                    }

            //                                    treeview.view :selected
            //                                    {
            //                                        background-color: rgb(10,106,182);
            //                                        color: white;
            //                                    }
            //.listt
            //{
            //font-family: Segoe UI;
            //}
            //                                    .dark2
            //                                    {
            //                                        color: gray;
            //                                        background: rgb(35,35,35);
            //                                        /*background: rgb(36,41,46);*/
            //                                    }
            //                                    .toolbar-border-dark
            //                                    {
            //                                        border-bottom: 1px solid rgb(20,20,20);
            //                                    }
            //                                    .toolbar-border-light
            //                                    {
            //                                        border-bottom: 2px solid rgb(240,240,240);
            //                                    }
            //                                  ");
            //Gtk.StyleContext.AddProviderForScreen(screen, provider, 800);

            ServicePointManager.ServerCertificateValidationCallback += (a, b, c, d) => true;
            ServicePointManager.DefaultConnectionLimit = 100;

            ServicePointManager.SecurityProtocol = SecurityProtocolType.SystemDefault;

            AppContext.SetSwitch(DisableCachingName, true);
            AppContext.SetSwitch(DontEnableSchUseStrongCryptoName, true);

            TextResource.Load(Config.Instance.Language);

            var debugMode = Environment.GetEnvironmentVariable("XDM_DEBUG_MODE");

            if (!string.IsNullOrEmpty(debugMode) && debugMode == "1")
            {
                var logFile = System.IO.Path.Combine(Config.DataDir, "log.txt");
                Log.InitFileBasedTrace(System.IO.Path.Combine(Config.DataDir, "log.txt"));
            }
            Log.Debug("Application_Startup");

            if (Config.Instance.AllowSystemDarkTheme)
            {
                Gtk.Settings.Default.ThemeName = "Adwaita";
                Gtk.Settings.Default.ApplicationPreferDarkTheme = true;
            }

            var core = new ApplicationCore();
            var app  = new XDMApp();
            var win  = new MainWindow();

            ApplicationContext.Configurer()
            .RegisterApplicationWindow(win)
            .RegisterApplication(app)
            .RegisterApplicationCore(core)
            .RegisterCapturedVideoTracker(new VideoTracker())
            .RegisterClipboardMonitor(new ClipboardMonitor())
            .RegisterLinkRefresher(new LinkRefresher())
            .RegisterPlatformUIService(new GtkPlatformUIService())
            .Configure();

            var commandOptions = ArgsProcessor.ParseArgs(args, 0);

            if (!commandOptions.ContainsKey("-m"))
            {
                win.Show();
                if (commandOptions.ContainsKey("-i"))
                {
                    Config.Instance.RunOnLogon = true;
                    Config.SaveConfig();
                    ApplicationContext.PlatformUIService.ShowBrowserMonitoringDialog();
                }
            }

            //var t = new System.Threading.Thread(() =>
            //  {
            //      while (true)
            //      {
            //          System.Threading.Thread.Sleep(5000);
            //          Console.WriteLine("Trigger GC");
            //          GC.Collect();
            //      }
            //  });
            //t.Start();

            Gtk.Application.Run();

            //var app = new XDM.Core.XDM.Core();
            //var appWin = new AppWinPeer(app);
            //appWin.ShowAll();
            //Application.Run();


            //            Environment.SetEnvironmentVariable("PANGOCAIRO_BACKEND", "fc", EnvironmentVariableTarget.User);
            //            //Console.WriteLine(Environment.GetEnvironmentVariable("PANGOCAIRO_BACKEND"));
            //            //var arr = new string[] {  "PANGOCAIRO_BACKEND=fc" };
            //            Application.Init();// "app", ref arr);
            //            Gtk.Settings.Default.ThemeName = "Adwaita";
            //            Gtk.Settings.Default.ApplicationPreferDarkTheme = true;

            //            App app = new App();



            //            var appWin = new AppWin();
            //            Console.WriteLine("Starting show all");
            //            appWin.Show();
            //            Console.WriteLine("Finished show all");
            //            Application.Run();
        }
Beispiel #17
0
            internal static void TestCorrectness()
            {
                ArgsProcessor ap = new ArgsProcessor();

                ap.Process(
                    new string[] { "cc", "-o", "test", "test.c", "-h", "-O3", "--verbose", "test.cc.log" },
                    new string[] { "-o", "--verbose" },
                    new string[] { "/h", "-h", "-O3" });

                foreach (var item in ap.PlainArgs)
                {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.MapArgs)
                {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.SwitchArgs)
                {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                Console.WriteLine();

                ap.Process(
                    new string[] { },
                    new string[] { "-o", "--verbose" });

                foreach (var item in ap.PlainArgs)
                {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.MapArgs)
                {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.SwitchArgs)
                {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                Console.WriteLine();

                ap.Process(null);
                foreach (var item in ap.PlainArgs)
                {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.MapArgs)
                {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.SwitchArgs)
                {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                Console.WriteLine();

                ap.Process(
                    new string[] { "cc", "-o", "test", "test.c", "-h", "-O3", "--verbose", "test.cc.log" },
                    switchs: new string[] { "/h", "-h", "-O3" });
                foreach (var item in ap.PlainArgs)
                {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.MapArgs)
                {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.SwitchArgs)
                {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                Console.WriteLine();
            }
Beispiel #18
0
        private Tuple <bool, XsltError> ProcessArgs(string[] args)
        {
            if (args == null || args.Length == 0)
            {
                DisplayCommandError(XsltError.MissingSource);
                return(Tuple.Create(false, XsltError.MissingSource));
            }

            ArgsProcessor             pro         = new ArgsProcessor(args);
            Tuple <XsltError, string> paramsError = Tuple.Create(XsltError.None, string.Empty);

            // Process the switches first
            foreach (Arg arg in pro)
            {
                string command = arg.Command.ToLower(CultureInfo.CurrentCulture);

                switch (command)
                {
                case "":
                {
                    paramsError = this.ProcessParams(arg.Options, 0);
                    break;
                }

                case "?":
                {
                    DisplayHelp();
                    return(Tuple.Create(false, XsltError.None));
                }

                case "-":
                case "/":
                {
                    if (!this.useSourceStdIn && string.IsNullOrEmpty(this.sourceFile))
                    {
                        this.useSourceStdIn = true;
                    }
                    else if (!this.useStylesheetStdIn && string.IsNullOrEmpty(this.stylesheetFile))
                    {
                        this.useStylesheetStdIn = true;
                    }
                    else
                    {
                        DisplayCommandError(XsltError.MSXSL_E_UNKNOWN_OPTION, string.Empty);
                        return(Tuple.Create(false, XsltError.MSXSL_E_UNKNOWN_OPTION));
                    }

                    paramsError = this.ProcessParams(arg.Options, 0);

                    break;
                }

                case "o":
                {
                    paramsError = this.ProcessParams(arg.Options, 1);

                    if (arg.Options.Length == 0 ||
                        string.IsNullOrEmpty(arg.Options[0]))
                    {
                        DisplayCommandError(XsltError.MissingOutput);
                        return(Tuple.Create(false, XsltError.MissingOutput));
                    }
                    else
                    {
                        this.useOutputfile = true;
                        this.outputfile    = arg.Options[0];
                    }

                    break;
                }

                case "t":
                {
                    paramsError = this.ProcessParams(arg.Options, 0);

                    this.useTimings = true;
                    break;
                }

                case "m":
                {
                    paramsError = this.ProcessParams(arg.Options, 1);

                    if (arg.Options.Length == 0)
                    {
                        DisplayCommandError(XsltError.MSXSL_E_MISSING_MODE);
                        return(Tuple.Create(false, XsltError.MSXSL_E_MISSING_MODE));
                    }
                    else
                    {
                        this.xsltOptions.StartMode = arg.Options[0];
                    }

                    break;
                }

                case "u":
                {
                    paramsError = this.ProcessParams(arg.Options, 1);
                    break;
                }

                case "pi":
                {
                    paramsError = this.ProcessParams(arg.Options, 0);

                    if (this.useStylesheetStdIn ||
                        !string.IsNullOrEmpty(this.stylesheetFile))
                    {
                        DisplayCommandError(XsltError.ProcessingInstructionConflict);
                        return(Tuple.Create(false, XsltError.ProcessingInstructionConflict));
                    }

                    this.useProcessingInstruction = true;
                    break;
                }

                case "xw":
                {
                    paramsError = this.ProcessParams(arg.Options, 0);

                    this.xsltOptions.RemoveWhitespace = true;
                    break;
                }

                case "v":
                {
                    paramsError = this.ProcessParams(arg.Options, 0);

                    this.validate = true;
                    break;
                }

                case "xe":
                {
                    paramsError = this.ProcessParams(arg.Options, 0);

                    this.xsltOptions.ExternalDefinitions = false;
                    break;
                }

                default:
                {
                    DisplayCommandError(XsltError.MSXSL_E_UNKNOWN_OPTION, command);
                    return(Tuple.Create(false, XsltError.MSXSL_E_UNKNOWN_OPTION));
                }
                }

                if (paramsError.Item1 != XsltError.None)
                {
                    DisplayCommandError(paramsError.Item1, paramsError.Item2);
                    return(Tuple.Create(false, paramsError.Item1));
                }
            }

            if (!this.useSourceStdIn && string.IsNullOrEmpty(this.sourceFile))
            {
                DisplayCommandError(XsltError.MissingSource);
                return(Tuple.Create(false, XsltError.MissingSource));
            }

            if (!this.useStylesheetStdIn && string.IsNullOrEmpty(this.stylesheetFile) && !this.useProcessingInstruction)
            {
                DisplayCommandError(XsltError.MissingStyleSheet);
                return(Tuple.Create(false, XsltError.MissingStyleSheet));
            }

            if (this.useSourceStdIn && this.useStylesheetStdIn)
            {
                DisplayCommandError(XsltError.MSXSL_E_MULTIPLE_STDIN);
                return(Tuple.Create(false, XsltError.MSXSL_E_MULTIPLE_STDIN));
            }

            return(Tuple.Create(true, XsltError.None));
        }
Beispiel #19
0
 public string ProcessArgString(string args)
 {
     return(ArgsProcessor.ProcessString(args, true));
 }
Beispiel #20
0
            internal static void TestCorrectness() {
                ArgsProcessor ap = new ArgsProcessor();
                ap.Process(
                    new string[] { "cc", "-o", "test", "test.c", "-h", "-O3", "--verbose", "test.cc.log" },
                    new string[] { "-o", "--verbose" },
                    new string[] { "/h", "-h", "-O3" });

                foreach (var item in ap.PlainArgs) {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.MapArgs) {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.SwitchArgs) {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                Console.WriteLine();

                ap.Process(
                    new string[] { },
                    new string[] { "-o", "--verbose" });

                foreach (var item in ap.PlainArgs) {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.MapArgs) {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.SwitchArgs) {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                Console.WriteLine();

                ap.Process(null);
                foreach (var item in ap.PlainArgs) {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.MapArgs) {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.SwitchArgs) {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                Console.WriteLine();

                ap.Process(
                    new string[] { "cc", "-o", "test", "test.c", "-h", "-O3", "--verbose", "test.cc.log" },
                    switchs: new string[] { "/h", "-h", "-O3" });
                foreach (var item in ap.PlainArgs) {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.MapArgs) {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                foreach (var item in ap.SwitchArgs) {
                    Console.Write(item + " ");
                }
                Console.WriteLine();
                Console.WriteLine();
            }