Added Archive Name

This commit is contained in:
vpenades
2022-06-13 13:34:21 +02:00
parent b205e2a84f
commit 8ea8dcde19
7 changed files with 35 additions and 17 deletions

View File

@@ -76,9 +76,7 @@ namespace SharpCompress.Archives
}
var extensions = Factories
.SelectMany(item => item.GetSupportedExtensions())
.Select(item => item.Key)
.Distinct()
.Select(item => item.Name)
.Aggregate((a,b) => a + ", " + b );
throw new InvalidOperationException($"Cannot determine compressed stream type. Supported Archive Formats: {extensions}");

View File

@@ -10,9 +10,12 @@ namespace SharpCompress.Archives.GZip
public class GZipArchiveFactory : IArchiveFactory
{
/// <inheritdoc/>
public IEnumerable<KeyValuePair<string, string>> GetSupportedExtensions()
public string Name => "GZip";
/// <inheritdoc/>
public IEnumerable<string> GetSupportedExtensions()
{
yield return new KeyValuePair<string, string>("GZip", "gz");
yield return "gz";
}
/// <inheritdoc/>

View File

@@ -22,11 +22,16 @@ namespace SharpCompress.Archives
/// </remarks>
public interface IArchiveFactory
{
/// <summary>
/// Gets the archive Type name
/// </summary>
string Name { get; }
/// <summary>
/// returns the extensions typically used by this archive type.
/// </summary>
/// <returns></returns>
IEnumerable<KeyValuePair<string, string>> GetSupportedExtensions();
IEnumerable<string> GetSupportedExtensions();
/// <summary>
/// Returns true if the stream represents an archive of the format defined by this type.

View File

@@ -10,10 +10,13 @@ namespace SharpCompress.Archives.Rar
public class RarArchiveFactory : IArchiveFactory
{
/// <inheritdoc/>
public IEnumerable<KeyValuePair<string, string>> GetSupportedExtensions()
public string Name => "Rar";
/// <inheritdoc/>
public IEnumerable<string> GetSupportedExtensions()
{
yield return new KeyValuePair<string, string>("Rar", "rar");
yield return new KeyValuePair<string, string>("Rar", "cbr");
yield return "rar";
yield return "cbr";
}
/// <inheritdoc/>

View File

@@ -10,9 +10,12 @@ namespace SharpCompress.Archives.SevenZip
public class SevenZipArchiveFactory : IArchiveFactory
{
/// <inheritdoc/>
public IEnumerable<KeyValuePair<string, string>> GetSupportedExtensions()
public string Name => "7Zip";
/// <inheritdoc/>
public IEnumerable<string> GetSupportedExtensions()
{
yield return new KeyValuePair<string, string>("7Zip", "7z");
yield return "7z";
}
/// <inheritdoc/>

View File

@@ -10,9 +10,12 @@ namespace SharpCompress.Archives.Tar
public class TarArchiveFactory : IArchiveFactory
{
/// <inheritdoc/>
public IEnumerable<KeyValuePair<string, string>> GetSupportedExtensions()
public string Name => "Tar";
/// <inheritdoc/>
public IEnumerable<string> GetSupportedExtensions()
{
yield return new KeyValuePair<string, string>("Tar", "tar");
yield return "tar";
}
/// <inheritdoc/>

View File

@@ -10,11 +10,14 @@ namespace SharpCompress.Archives.Zip
public class ZipArchiveFactory : IArchiveFactory
{
/// <inheritdoc/>
public IEnumerable<KeyValuePair<string, string>> GetSupportedExtensions()
public string Name => "Zip";
/// <inheritdoc/>
public IEnumerable<string> GetSupportedExtensions()
{
yield return new KeyValuePair<string, string>("Zip", "zip");
yield return new KeyValuePair<string, string>("Zip", "zipx");
yield return new KeyValuePair<string, string>("Zip", "cbz");
yield return "zip";
yield return "zipx";
yield return "cbz";
}
/// <inheritdoc/>