/// <summary> /// Deserialize PluginInfo from json /// </summary> /// <param name="json">Json data of PluginInfo</param> /// <returns>True if data are loaded, otherwise False</returns> protected virtual bool DeserializePluginInfo(string json) { var pluginsInfo = JsonConvert.DeserializeObject <PluginsInfo>(json); InstalledPluginNames = pluginsInfo.InstalledPluginNames; PluginNamesToUninstall = pluginsInfo.PluginNamesToUninstall; PluginNamesToDelete = pluginsInfo.PluginNamesToDelete; PluginNamesToInstall = pluginsInfo.PluginNamesToInstall; return(InstalledPluginNames.Any() || PluginNamesToUninstall.Any() || PluginNamesToDelete.Any() || PluginNamesToInstall.Any()); }
/// <summary> /// Get plugins info /// </summary> /// <returns>True if data are loaded, otherwise False</returns> public virtual bool LoadPluginInfo() { //check whether plugins info file exists var filePath = _fileProvider.MapPath(QNetPluginDefaults.PluginsInfoFilePath); if (!_fileProvider.FileExists(filePath)) { //file doesn't exist, so try to get only installed plugin names from the obsolete file InstalledPluginNames = GetObsoleteInstalledPluginNames(); //and save info into a new file if need if (InstalledPluginNames.Any()) { Save(); } } //try to get plugin info from the JSON file var text = _fileProvider.FileExists(filePath) ? _fileProvider.ReadAllText(filePath, Encoding.UTF8) : string.Empty; return(!string.IsNullOrEmpty(text) && DeserializePluginInfo(text)); }