Example #1
0
        internal async Task ParseAsync()
        {
            if (!File.Exists(LocalCachePath))
                return;

            try
            {
                using (var reader = new StreamReader(LocalCachePath))
                {
                    string json = await reader.ReadToEndAsync();
                    var root = JObject.Parse(json);

                    foreach (JProperty obj in root.Children<JProperty>())
                    {
                        JEnumerable<JProperty> child = obj.Children<JProperty>();

                        var entry = new ExtensionEntry()
                        {
                            Name = obj.Name,
                            Id = (string)root[obj.Name]["id"],
                            MinVersion = new Version((string)root[obj.Name]["minVersion"] ?? "15.0"),
                            MaxVersion = new Version((string)root[obj.Name]["maxVersion"] ?? "16.0")
                        };

                        Extensions.Add(entry);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write(ex);
            }
        }
Example #2
0
 public LogMessage(ExtensionEntry entry, string action)
 {
     Id     = entry.Id;
     Name   = entry.Name;
     Action = action;
     Date   = DateTime.Now;
 }
Example #3
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);
                }
            }
        }
Example #4
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
            {
            }
        }
Example #5
0
 public void MarkUninstalled(ExtensionEntry extension)
 {
     Log.Add(new LogMessage(extension, _uninstalled));
 }