public void DeletePlugin(Plugin plugin)
        {
            var pluginKeys = _liveWriterPluginsRegistryKey.GetValueNames();
            if (!pluginKeys.Contains(plugin.Name))
            {
                return;
            }

            _liveWriterPluginsRegistryKey.DeleteValue(plugin.Name, false);

            var file = new FileInfo(plugin.Path);
            var path = file.Directory;
            if (path?.Exists ?? false)
            {
                path.Delete(true);
            }
        }
        public async Task<Plugin> UnzipFileAsync(string filePath)
        {
            Plugin result = null;
            if (string.IsNullOrEmpty(filePath))
            {
                return result;
            }

            try
            {
            var tcs = new TaskCompletionSource<bool>();
                await Task.Run(async () =>
                {
                    using (var zipFile = ZipFile.Read(filePath))
                    {
                        zipFile.FlattenFoldersOnExtract = true;
                        var fileName = Path.GetFileNameWithoutExtension(filePath);

                        var extractPath = Path.Combine(AppHelper.PluginsFolder, fileName);
                        zipFile.ExtractAll(extractPath, ExtractExistingFileAction.OverwriteSilently);

                        var pluginFile = await CheckExtractedFilesForPlugin(extractPath);

                        result = new Plugin
                        {
                            Name = fileName,
                            Path = pluginFile?.FullName
                        };

                        tcs.SetResult(true);
                    }
                });

                await tcs.Task;
            }
            catch (Exception ex)
            {
                // TODO: something here
            }

            return result;
        }
        public async Task<Plugin> UnzipFileAsync(string filePath)
        {
            Plugin result = null;
            if (string.IsNullOrEmpty(filePath))
            {
                return result;
            }

            try
            {
                var tcs = new TaskCompletionSource<bool>();
                await Task.Run(async () =>
                {
                    var fileName = Path.GetFileNameWithoutExtension(filePath);
                    var extractPath = Path.Combine(AppHelper.PluginsFolder, fileName);

                    var manifest = await ExtractAndReturnManifest(extractPath, filePath);

                    result = new Plugin
                    {
                        Name = manifest?.Name,
                        Path = manifest?.PluginPath
                    };

                    tcs.SetResult(true);
                });

                await tcs.Task;
            }
            catch (Exception ex)
            {
                await _messageService.ShowErrorAsync("There was an error unpacking this zip file: " + ex.Message);
            }

            return result;
        }
 public PluginViewModel(Plugin plugin, ILiveWriterService liveWriterService)
 {
     Plugin = plugin;
     _liveWriterService = liveWriterService;
 }
 public void SavePlugin(Plugin plugin)
 {
     _liveWriterPluginsRegistryKey.SetValue(plugin.Name, plugin.Path, RegistryValueKind.String);
 }
 public PluginViewModel(Plugin plugin, ILiveWriterService liveWriterService, IMessageService messageService)
 {
     Plugin = plugin;
     _liveWriterService = liveWriterService;
     _messageService = messageService;
 }