コード例 #1
0
        void packageManagerProxy_PackageInstalling(object sender, PackageOperationEventArgs e)
        {
            var package    = e.Package;
            var entryPoint = package.Id + Constants.BonsaiExtension;

            if (package.GetContentFiles().Any(file => file.EffectivePath == entryPoint))
            {
                Invoke((Action)(() =>
                {
                    var message = string.Format(Resources.InstallExecutablePackageWarning, package.Id);
                    var result = MessageBox.Show(this, message, Resources.InstallExecutablePackageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                    if (result == DialogResult.Yes)
                    {
                        saveFolderDialog.FileName = package.Id;
                        if (saveFolderDialog.ShowDialog(this) == DialogResult.OK)
                        {
                            var targetPath = saveFolderDialog.FileName;
                            var targetFileSystem = new PhysicalFileSystem(targetPath);
                            InstallPath = PackageHelper.InstallExecutablePackage(package, targetFileSystem);
                            DialogResult = DialogResult.OK;
                        }
                    }
                }));
            }
        }
コード例 #2
0
ファイル: Launcher.cs プロジェクト: aalmada/bonsai
        static string LaunchPackageBootstrapper(
            PackageConfiguration packageConfiguration,
            string editorRepositoryPath,
            string editorPath,
            string targetPath,
            string packageId,
            Func <IPackageManager, Task> installPackage)
        {
            EnableVisualStyles();
            var installPath       = string.Empty;
            var executablePackage = default(IPackage);
            var packageManager    = CreatePackageManager(editorRepositoryPath);

            using (var monitor = new PackageConfigurationUpdater(packageConfiguration, packageManager, editorPath))
            {
                packageManager.PackageInstalling += (sender, e) =>
                {
                    var package = e.Package;
                    if (package.Id == packageId && e.Cancel)
                    {
                        executablePackage = package;
                    }
                };

                PackageHelper.RunPackageOperation(packageManager, () => installPackage(packageManager));
            }

            if (executablePackage != null)
            {
                if (string.IsNullOrEmpty(targetPath))
                {
                    var entryPoint = executablePackage.Id + NuGet.Constants.BonsaiExtension;
                    var message    = string.Format(Resources.InstallExecutablePackageWarning, executablePackage.Id);
                    var result     = MessageBox.Show(message, Resources.InstallExecutablePackageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                    if (result == DialogResult.Yes)
                    {
                        using (var dialog = new SaveFolderDialog())
                        {
                            dialog.FileName = executablePackage.Id;
                            if (dialog.ShowDialog() == DialogResult.OK)
                            {
                                targetPath = dialog.FileName;
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(targetPath))
                {
                    var targetFileSystem = new PhysicalFileSystem(targetPath);
                    installPath = PackageHelper.InstallExecutablePackage(executablePackage, targetFileSystem);
                }
            }
            return(installPath);
        }
コード例 #3
0
ファイル: GalleryDialog.cs プロジェクト: aalmada/bonsai
        void packageManagerProxy_PackageInstalling(object sender, PackageOperationEventArgs e)
        {
            var package = e.Package;

            if (package == targetPackage)
            {
                var entryPoint = package.Id + Constants.BonsaiExtension;
                if (!package.GetContentFiles().Any(file => file.EffectivePath == entryPoint))
                {
                    var message = string.Format(Resources.MissingWorkflowEntryPoint, entryPoint);
                    throw new InvalidOperationException(message);
                }

                var targetFileSystem = new PhysicalFileSystem(targetPath);
                InstallPath  = PackageHelper.InstallExecutablePackage(package, targetFileSystem);
                DialogResult = DialogResult.OK;
            }
        }