public static async Task InstallAssembly(AssemblyEntry assembly, bool silent)
        {
            if (Config.Instance.SelectedProfile.InstalledAssemblies.Any(a => a.Name == assembly.Name))
            {
                return;
            }

            try
            {
                var projectName     = Path.GetFileNameWithoutExtension(new Uri(assembly.GithubUrl).AbsolutePath);
                var repositoryMatch = Regex.Match(assembly.GithubUrl, @"^(http[s]?)://(?<host>.*?)/(?<author>.*?)/(?<repo>.*?)(/{1}|$)");
                var repositoryUrl   = $"https://{repositoryMatch.Groups["host"]}/{repositoryMatch.Groups["author"]}/{repositoryMatch.Groups["repo"]}";

                var installer = new InstallerWindow {
                    Owner = MainWindow.Instance
                };

                if (silent)
                {
                    await installer.ListAssemblies(repositoryUrl, true, true, HttpUtility.UrlDecode(projectName));

                    installer.Close();
                    return;
                }

                installer.ShowProgress(repositoryUrl, true, HttpUtility.UrlDecode(projectName));
                installer.ShowDialog();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 2
0
        public static async Task InstallAssembly(AssemblyEntry assembly, bool silent)
        {
            if (Config.Instance.SelectedProfile.InstalledAssemblies.Any(a => a.Name == assembly.Name))
            {
                return;
            }

            try
            {
                var projectName     = Path.GetFileNameWithoutExtension(new Uri(assembly.GithubUrl).AbsolutePath).WebDecode();
                var repositoryMatch = Regex.Match(assembly.GithubUrl, @"^(http[s]?)://(?<host>.*?)/(?<author>.*?)/(?<repo>.*?)(/{1}|$)");
                var repositoryUrl   = $"https://{repositoryMatch.Groups["host"]}/{repositoryMatch.Groups["author"]}/{repositoryMatch.Groups["repo"]}";

                // HACK: :^)
                var redirect = Config.Instance.BlockedRepositories.Where(r => r.HasRedirect).FirstOrDefault(r => repositoryUrl.StartsWith(r.Url));
                if (redirect != null)
                {
                    repositoryUrl = redirect.Redirect;
                }

                var installer = new InstallerWindow {
                    Owner = MainWindow.Instance
                };

                if (silent)
                {
                    await installer.ListAssemblies(repositoryUrl, true, true, projectName);

                    installer.Close();
                    return;
                }

                installer.ShowProgress(repositoryUrl, true, projectName);
                installer.ShowDialog();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public static async Task InstallAssembly(AssemblyEntry assembly, bool silent)
        {
            if (Config.Instance.SelectedProfile.InstalledAssemblies.Any(a => a.Name == assembly.Name))
            {
                return;
            }

            try
            {
                var projectName = Path.GetFileNameWithoutExtension(new Uri(assembly.GithubUrl).AbsolutePath);
                var repositoryMatch = Regex.Match(assembly.GithubUrl, @"^(http[s]?)://(?<host>.*?)/(?<author>.*?)/(?<repo>.*?)(/{1}|$)");
                var repositoryUrl = $"https://{repositoryMatch.Groups["host"]}/{repositoryMatch.Groups["author"]}/{repositoryMatch.Groups["repo"]}";

                var installer = new InstallerWindow { Owner = MainWindow.Instance };

                if (silent)
                {
                    await installer.ListAssemblies(repositoryUrl, true, true, HttpUtility.UrlDecode(projectName));
                    installer.Close();
                    return;
                }

                installer.ShowProgress(repositoryUrl, true, HttpUtility.UrlDecode(projectName));
                installer.ShowDialog();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }