/// <summary> /// Get system names of installed plugins from obsolete file /// </summary> /// <returns>List of plugin system names</returns> protected virtual IList <string> GetObsoleteInstalledPluginNames() { //check whether file exists string filePath = _fileProvider.MapPath(VerivoxPluginDefaults.InstalledPluginsFilePath); if (!_fileProvider.FileExists(filePath)) { //if not, try to parse the file that was used in previous nopCommerce versions filePath = _fileProvider.MapPath(VerivoxPluginDefaults.ObsoleteInstalledPluginsFilePath); if (!_fileProvider.FileExists(filePath)) { return(new List <string>()); } //get plugin system names from the old txt file List <string> pluginSystemNames = new List <string>(); using (StringReader reader = new StringReader(_fileProvider.ReadAllText(filePath, Encoding.UTF8))) { string pluginName; while ((pluginName = reader.ReadLine()) != null) { if (!string.IsNullOrWhiteSpace(pluginName)) { pluginSystemNames.Add(pluginName.Trim()); } } } //and delete the old one _fileProvider.DeleteFile(filePath); return(pluginSystemNames); } string text = _fileProvider.ReadAllText(filePath, Encoding.UTF8); if (string.IsNullOrEmpty(text)) { return(new List <string>()); } //delete the old file _fileProvider.DeleteFile(filePath); //get plugin system names from the JSON file return(JsonConvert.DeserializeObject <IList <string> >(text)); }
/// <summary> /// Save plugin descriptor to the plugin description file /// </summary> public virtual void Save() { IVerivoxFileProvider fileProvider = EngineContext.Current.Resolve <IVerivoxFileProvider>(); //get the description file path if (OriginalAssemblyFile == null) { throw new Exception($"Cannot load original assembly path for {SystemName} plugin."); } string filePath = fileProvider.Combine(fileProvider.GetDirectoryName(OriginalAssemblyFile), VerivoxPluginDefaults.DescriptionFileName); if (!fileProvider.FileExists(filePath)) { throw new Exception($"Description file for {SystemName} plugin does not exist. {filePath}"); } //save the file string text = JsonConvert.SerializeObject(this, Formatting.Indented); fileProvider.WriteAllText(filePath, text, Encoding.UTF8); }