/// <summary> /// Copy the directory /// </summary> /// <param name="sourcePath">Path to the source directory</param> /// <param name="destinationPath">Path to the destination directory</param> /// <returns>A task that represents the completion of the operation</returns> protected virtual async Task CopyDirectoryAsync(string sourcePath, string destinationPath) { var directoryPath = GetFullPath(GetVirtualPath(sourcePath)); if (!_fileProvider.DirectoryExists(directoryPath)) { throw new Exception(GetLanguageResource("E_CopyDirInvalidPath")); } var newDirectoryPath = GetFullPath(GetVirtualPath($"{destinationPath.TrimEnd('/')}/{_fileProvider.GetDirectoryName(directoryPath)}")); if (_fileProvider.DirectoryExists(newDirectoryPath)) { throw new Exception(GetLanguageResource("E_DirAlreadyExists")); } CopyDirectory(directoryPath, newDirectoryPath); await HttpContext.Response.WriteAsync(GetSuccessResponse()); }
/// <summary> /// Get description files /// </summary> /// <param name="pluginFolder">Plugin directory info</param> /// <returns>Original and parsed description files</returns> private static IEnumerable <KeyValuePair <string, PluginDescriptor> > GetDescriptionFilesAndDescriptors(string pluginFolder) { if (pluginFolder == null) { throw new ArgumentNullException(nameof(pluginFolder)); } //create list (<file info, parsed plugin descritor>) var result = new List <KeyValuePair <string, PluginDescriptor> >(); //add display order and path to list foreach (var descriptionFile in _fileProvider.GetFiles(pluginFolder, GSPluginDefaults.DescriptionFileName, false)) { if (!IsPackagePluginFolder(_fileProvider.GetDirectoryName(descriptionFile))) { continue; } //parse file var pluginDescriptor = GetPluginDescriptorFromFile(descriptionFile); //populate list result.Add(new KeyValuePair <string, PluginDescriptor>(descriptionFile, pluginDescriptor)); } //sort list by display order. NOTE: Lowest DisplayOrder will be first i.e 0 , 1, 1, 1, 5, 10 //it's required: https://www.nopcommerce.com/boards/t/17455/load-plugins-based-on-their-displayorder-on-startup.aspx result.Sort((firstPair, nextPair) => firstPair.Value.DisplayOrder.CompareTo(nextPair.Value.DisplayOrder)); return(result); }