コード例 #1
0
        private void InstallExtension(IVsExtensionRepository repository, IVsExtensionManager manager, KeyValuePair <string, string> product, DataStore store)
        {
#if DEBUG
            System.Threading.Thread.Sleep(1000);
            return;
#endif

            GalleryEntry entry = null;

            try
            {
                entry = repository.CreateQuery <GalleryEntry>(includeTypeInQuery: false, includeSkuInQuery: true, searchSource: "ExtensionManagerUpdate")
                        .Where(e => e.VsixID == product.Key)
                        .AsEnumerable()
                        .FirstOrDefault();

                if (entry != null)
                {
                    var installable = repository.Download(entry);
                    manager.Install(installable, false);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
            finally
            {
                if (entry != null)
                {
                    store.PreviouslyInstalledExtensions.Add(entry.VsixID);
                }
            }
        }
コード例 #2
0
        private void InstallExtension(ExtensionEntry extension, IVsExtensionRepository repository, IVsExtensionManager manager)
        {
            GalleryEntry entry = null;

            OnUpdate(string.Format(Resources.Text.InstallingExtension, extension.Name));

            try
            {
                Logger.Log($"{Environment.NewLine}{extension.Name}");
                Logger.Log("  " + Resources.Text.Verifying, false);

                entry = repository.GetVSGalleryExtensions <GalleryEntry>(new List <string> {
                    extension.Id
                }, 1033, false)?.FirstOrDefault();

                if (entry != null)
                {
                    Logger.Log(Resources.Text.Ok); // Marketplace ok
                    Logger.Log("  " + Resources.Text.Downloading, false);
#if !DEBUG
                    IInstallableExtension installable = repository.Download(entry);
#endif
                    Logger.Log(Resources.Text.Ok); // Download ok
                    Logger.Log("  " + Resources.Text.Installing, false);
#if !DEBUG
                    manager.Install(installable, false);
#else
                    Thread.Sleep(2000);
#endif
                    Logger.Log(Resources.Text.Ok); // Install ok
                    Telemetry.Install(extension.Id, true);
                }
                else
                {
                    Logger.Log(Resources.Text.Failed); // Markedplace failed
                }
            }
            catch (Exception)
            {
                Logger.Log(Resources.Text.Failed);
                Telemetry.Install(extension.Id, false);
            }
            finally
            {
                if (entry != null)
                {
                    Store.MarkInstalled(extension);
                }
            }
        }
コード例 #3
0
        public void InstallExtension(ExtensionEntry extension, IVsExtensionRepository repository, IVsExtensionManager manager)
        {
            GalleryEntry entry = null;

            OnUpdate(string.Format("Installing Extension: ", extension.Name));

            try
            {
                Logger.Log($"{Environment.NewLine}{extension.Name}");
                Logger.Log("  " + "Verifying ", false);

                entry = repository.GetVSGalleryExtensions <GalleryEntry>(new List <string> {
                    extension.Id
                }, 1033, false)?.FirstOrDefault();

                if (entry != null)
                {
                    Logger.Log("Marketplace OK"); // Marketplace ok
                    Logger.Log("  " + "Downloading", false);

                    IInstallableExtension installable = repository.Download(entry);
                    Logger.Log("Downloading OK"); // Download ok
                    Logger.Log("  " + "Installing", false);
                    manager.Install(installable, false);
                    Logger.Log("Install OK"); // Install ok
                    Telemetry.Install(extension.Id, true);
                }
                else
                {
                    Logger.Log("Marketplace failed"); // Markedplace failed
                }
            }
            catch (Exception)
            {
                Logger.Log("Install failed exception");
                Telemetry.Install(extension.Id, false);
            }
            finally
            {
            }
        }