Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Random cleanup looking for additional places to change from Dictionar…
Browse files Browse the repository at this point in the history
…y to IDictionary. Only found one case, in SevenZipCompressorAsynchronous.BeginModifyArchive.
  • Loading branch information
squid-box committed Apr 20, 2019
1 parent 5d2cca2 commit 8b5ff0d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 62 deletions.
3 changes: 2 additions & 1 deletion SevenZip.Tests/SevenZip.Tests.csproj
Expand Up @@ -10,10 +10,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SevenZip.Tests</RootNamespace>
<AssemblyName>SevenZip.Tests</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
8 changes: 4 additions & 4 deletions SevenZip/Formats.cs
Expand Up @@ -370,7 +370,7 @@ internal static int GetMaxValue(Type type)
/// List of readable archive format interface guids for 7-zip COM interop.
/// </summary>
internal static readonly Dictionary<InArchiveFormat, Guid> InFormatGuids =
new Dictionary<InArchiveFormat, Guid>(20)
new Dictionary<InArchiveFormat, Guid>
#region InFormatGuids initialization

{
Expand Down Expand Up @@ -428,7 +428,7 @@ internal static int GetMaxValue(Type type)
/// List of writable archive format interface guids for 7-zip COM interop.
/// </summary>
internal static readonly Dictionary<OutArchiveFormat, Guid> OutFormatGuids =
new Dictionary<OutArchiveFormat, Guid>(2)
new Dictionary<OutArchiveFormat, Guid>
#region OutFormatGuids initialization

{
Expand All @@ -443,7 +443,7 @@ internal static int GetMaxValue(Type type)
#endregion

internal static readonly Dictionary<CompressionMethod, string> MethodNames =
new Dictionary<CompressionMethod, string>(6)
new Dictionary<CompressionMethod, string>
#region MethodNames initialization

{
Expand All @@ -459,7 +459,7 @@ internal static int GetMaxValue(Type type)
#endregion

internal static readonly Dictionary<OutArchiveFormat, InArchiveFormat> InForOutFormats =
new Dictionary<OutArchiveFormat, InArchiveFormat>(6)
new Dictionary<OutArchiveFormat, InArchiveFormat>
#region InForOutFormats initialization

{
Expand Down
8 changes: 4 additions & 4 deletions SevenZip/LibraryManager.cs
Expand Up @@ -60,7 +60,7 @@ private static string DetermineLibraryFilePath()
private static int _totalUsers;

// private static string _LibraryVersion;
private static bool? _modifyCapabale;
private static bool? _modifyCapable;

private static void InitUserInFormat(object user, InArchiveFormat format)
{
Expand Down Expand Up @@ -151,12 +151,12 @@ public static bool ModifyCapable
{
lock (_syncRoot)
{
if (!_modifyCapabale.HasValue)
if (!_modifyCapable.HasValue)
{
FileVersionInfo dllVersionInfo = FileVersionInfo.GetVersionInfo(_libraryFileName);
_modifyCapabale = dllVersionInfo.FileMajorPart >= 9;
_modifyCapable = dllVersionInfo.FileMajorPart >= 9;
}
return _modifyCapabale.Value;
return _modifyCapable.Value;
}
}
}
Expand Down
78 changes: 29 additions & 49 deletions SevenZip/SevenZipCompressorAsynchronous.cs
Expand Up @@ -2,11 +2,11 @@
{
using System.Collections.Generic;
using System.IO;
using System.Threading;

partial class SevenZipCompressor
{
#region Delegates

private delegate void CompressFiles1Delegate(string archiveName, string[] fileFullNames);
private delegate void CompressFiles2Delegate(Stream archiveStream, string[] fileFullNames);
private delegate void CompressFiles3Delegate(string archiveName, int commonRootLength, string[] fileFullNames);
Expand All @@ -17,21 +17,13 @@ partial class SevenZipCompressor
private delegate void CompressFilesEncrypted3Delegate(string archiveName, int commonRootLength, string password, string[] fileFullNames);
private delegate void CompressFilesEncrypted4Delegate(Stream archiveStream, int commonRootLength, string password, string[] fileFullNames);

private delegate void CompressDirectory1Delegate(string directory, string archiveName);
private delegate void CompressDirectory2Delegate(string directory, Stream archiveStream);
private delegate void CompressDirectory3Delegate(string directory, string archiveName, string password);
private delegate void CompressDirectory4Delegate(string directory, Stream archiveStream, string password);
private delegate void CompressDirectory5Delegate(string directory, string archiveName,
string password, string searchPattern, bool recursion);
private delegate void CompressDirectory6Delegate(string directory, Stream archiveStream,
string password, string searchPattern, bool recursion);

private delegate void CompressStream1Delegate(Stream inStream, Stream outStream);
private delegate void CompressStream2Delegate(Stream inStream, Stream outStream, string password);

private delegate void ModifyArchive1Delegate(string archiveName, Dictionary<int, string> newFileNames);
private delegate void ModifyArchive2Delegate(string archiveName, Dictionary<int, string> newFileNames,
string password);
private delegate void CompressDirectoryDelegate(string directory, string archiveName, string password, string searchPattern, bool recursion);
private delegate void CompressDirectory2Delegate(string directory, Stream archiveStream, string password, string searchPattern, bool recursion);

private delegate void CompressStreamDelegate(Stream inStream, Stream outStream, string password);

private delegate void ModifyArchiveDelegate(string archiveName, IDictionary<int, string> newFileNames, string password);

#endregion

#region CompressFiles overloads
Expand All @@ -43,8 +35,7 @@ partial class SevenZipCompressor
public void BeginCompressFiles(string archiveName, params string[] fileFullNames)
{
SaveContext();
new CompressFiles1Delegate(CompressFiles).BeginInvoke(archiveName, fileFullNames,
AsyncCallbackImplementation, this);
new CompressFiles1Delegate(CompressFiles).BeginInvoke(archiveName, fileFullNames, AsyncCallbackImplementation, this);
}

/// <summary>
Expand All @@ -56,22 +47,19 @@ public void BeginCompressFiles(string archiveName, params string[] fileFullNames
public void BeginCompressFiles(Stream archiveStream, params string[] fileFullNames)
{
SaveContext();
new CompressFiles2Delegate(CompressFiles).BeginInvoke(archiveStream, fileFullNames,
AsyncCallbackImplementation, this);
new CompressFiles2Delegate(CompressFiles).BeginInvoke(archiveStream, fileFullNames, AsyncCallbackImplementation, this);
}

/// <summary>
/// Packs files into the archive asynchronously.
/// </summary>
/// <param name="fileFullNames">Array of file names to pack.</param>
/// <param name="commonRootLength">The length of the common root of the file names.</param>
/// <param name="archiveName">The archive file name.</param>
public void BeginCompressFiles(
string archiveName, int commonRootLength, params string[] fileFullNames)
public void BeginCompressFiles(string archiveName, int commonRootLength, params string[] fileFullNames)
{
SaveContext();
new CompressFiles3Delegate(CompressFiles).BeginInvoke(archiveName, commonRootLength, fileFullNames,
AsyncCallbackImplementation, this);
new CompressFiles3Delegate(CompressFiles).BeginInvoke(archiveName, commonRootLength, fileFullNames, AsyncCallbackImplementation, this);
}

/// <summary>
Expand All @@ -84,8 +72,7 @@ public void BeginCompressFiles(Stream archiveStream, params string[] fileFullNam
public void BeginCompressFiles(Stream archiveStream, int commonRootLength, params string[] fileFullNames)
{
SaveContext();
new CompressFiles4Delegate(CompressFiles).BeginInvoke(archiveStream, commonRootLength, fileFullNames,
AsyncCallbackImplementation, this);
new CompressFiles4Delegate(CompressFiles).BeginInvoke(archiveStream, commonRootLength, fileFullNames, AsyncCallbackImplementation, this);
}

/// <summary>
Expand All @@ -97,8 +84,7 @@ public void BeginCompressFiles(Stream archiveStream, int commonRootLength, param
public void BeginCompressFilesEncrypted(string archiveName, string password, params string[] fileFullNames )
{
SaveContext();
new CompressFilesEncrypted1Delegate(CompressFilesEncrypted).BeginInvoke(archiveName, password, fileFullNames,
AsyncCallbackImplementation, this);
new CompressFilesEncrypted1Delegate(CompressFilesEncrypted).BeginInvoke(archiveName, password, fileFullNames, AsyncCallbackImplementation, this);
}

/// <summary>
Expand All @@ -111,8 +97,7 @@ public void BeginCompressFilesEncrypted(string archiveName, string password, par
public void BeginCompressFilesEncrypted(Stream archiveStream, string password, params string[] fileFullNames)
{
SaveContext();
new CompressFilesEncrypted2Delegate(CompressFilesEncrypted).BeginInvoke(archiveStream, password, fileFullNames,
AsyncCallbackImplementation, this);
new CompressFilesEncrypted2Delegate(CompressFilesEncrypted).BeginInvoke(archiveStream, password, fileFullNames, AsyncCallbackImplementation, this);
}

/// <summary>
Expand All @@ -125,8 +110,7 @@ public void BeginCompressFilesEncrypted(Stream archiveStream, string password, p
public void BeginCompressFilesEncrypted(string archiveName, int commonRootLength, string password, params string[] fileFullNames)
{
SaveContext();
new CompressFilesEncrypted3Delegate(CompressFilesEncrypted).BeginInvoke(archiveName, commonRootLength, password,
fileFullNames, AsyncCallbackImplementation, this);
new CompressFilesEncrypted3Delegate(CompressFilesEncrypted).BeginInvoke(archiveName, commonRootLength, password,fileFullNames, AsyncCallbackImplementation, this);
}

/// <summary>
Expand All @@ -140,9 +124,9 @@ public void BeginCompressFilesEncrypted(string archiveName, int commonRootLength
public void BeginCompressFilesEncrypted(Stream archiveStream, int commonRootLength, string password, params string[] fileFullNames)
{
SaveContext();
new CompressFilesEncrypted4Delegate(CompressFilesEncrypted).BeginInvoke(archiveStream, commonRootLength, password,
fileFullNames, AsyncCallbackImplementation, this);
new CompressFilesEncrypted4Delegate(CompressFilesEncrypted).BeginInvoke(archiveStream, commonRootLength, password, fileFullNames, AsyncCallbackImplementation, this);
}

#endregion

#region BeginCompressDirectory overloads
Expand All @@ -155,12 +139,10 @@ public void BeginCompressFilesEncrypted(Stream archiveStream, int commonRootLeng
/// <param name="password">The archive password.</param>
/// <param name="searchPattern">Search string, such as "*.txt".</param>
/// <param name="recursion">If true, files will be searched for recursively; otherwise, not.</param>
public void BeginCompressDirectory(string directory, string archiveName,
string password = "", string searchPattern = "*", bool recursion = true)
public void BeginCompressDirectory(string directory, string archiveName, string password = "", string searchPattern = "*", bool recursion = true)
{
SaveContext();
new CompressDirectory5Delegate(CompressDirectory).BeginInvoke(directory, archiveName,
password, searchPattern, recursion, AsyncCallbackImplementation, this);
new CompressDirectoryDelegate(CompressDirectory).BeginInvoke(directory, archiveName, password, searchPattern, recursion, AsyncCallbackImplementation, this);
}

/// <summary>
Expand All @@ -172,14 +154,13 @@ public void BeginCompressFilesEncrypted(Stream archiveStream, int commonRootLeng
/// <param name="password">The archive password.</param>
/// <param name="searchPattern">Search string, such as "*.txt".</param>
/// <param name="recursion">If true, files will be searched for recursively; otherwise, not.</param>
public void BeginCompressDirectory(string directory, Stream archiveStream,
string password , string searchPattern = "*", bool recursion = true)
public void BeginCompressDirectory(string directory, Stream archiveStream, string password , string searchPattern = "*", bool recursion = true)
{
SaveContext();
new CompressDirectory6Delegate(CompressDirectory).BeginInvoke(directory, archiveStream,
password, searchPattern, recursion, AsyncCallbackImplementation, this);
new CompressDirectory2Delegate(CompressDirectory).BeginInvoke(directory, archiveStream, password, searchPattern, recursion, AsyncCallbackImplementation, this);
}
#endregion

#endregion

#region BeginCompressStream overloads

Expand All @@ -193,11 +174,11 @@ public void BeginCompressFilesEncrypted(Stream archiveStream, int commonRootLeng
public void BeginCompressStream(Stream inStream, Stream outStream, string password = "")
{
SaveContext();
(new CompressStream2Delegate(CompressStream)).BeginInvoke(inStream, outStream, password, AsyncCallbackImplementation, this);
new CompressStreamDelegate(CompressStream).BeginInvoke(inStream, outStream, password, AsyncCallbackImplementation, this);

}
#endregion

#region BeginModifyArchive overloads

/// <summary>
Expand All @@ -206,11 +187,10 @@ public void BeginCompressStream(Stream inStream, Stream outStream, string passwo
/// <param name="archiveName">The archive file name.</param>
/// <param name="newFileNames">New file names. Null value to delete the corresponding index.</param>
/// <param name="password">The archive password.</param>
public void BeginModifyArchive(string archiveName, Dictionary<int, string> newFileNames,
string password = "")
public void BeginModifyArchive(string archiveName, IDictionary<int, string> newFileNames, string password = "")
{
SaveContext();
new ModifyArchive2Delegate(ModifyArchive).BeginInvoke(archiveName, newFileNames, password, AsyncCallbackImplementation, this);
new ModifyArchiveDelegate(ModifyArchive).BeginInvoke(archiveName, newFileNames, password, AsyncCallbackImplementation, this);
}

#endregion
Expand Down
5 changes: 3 additions & 2 deletions SevenZip/SevenZipSfx.cs
Expand Up @@ -47,7 +47,7 @@ public class SevenZipSfx
{
get
{
var result = new Dictionary<SfxModule, List<string>>(3)
var result = new Dictionary<SfxModule, List<string>>
{
{SfxModule.Simple, new List<string>(2) {"7z.sfx", "7zCon.sfx"}},
{SfxModule.Installer, new List<string>(2) {"7zS.sfx", "7zSD.sfx"}}
Expand Down Expand Up @@ -89,8 +89,9 @@ public SevenZipSfx(SfxModule module)
{
if (module == SfxModule.Custom)
{
throw new ArgumentException("You must specify the custom module executable.", "module");
throw new ArgumentException("You must specify the custom module executable.", nameof(module));
}

_module = module;
CommonInit();
}
Expand Down
3 changes: 1 addition & 2 deletions SevenZip/StreamWrappers.cs
Expand Up @@ -230,8 +230,7 @@ private void OnBytesWritten(IntEventArgs e)
/// </summary>
internal class MultiStreamWrapper : DisposeVariableWrapper, IDisposable
{
protected readonly Dictionary<int, KeyValuePair<long, long>> StreamOffsets =
new Dictionary<int, KeyValuePair<long, long>>();
protected readonly Dictionary<int, KeyValuePair<long, long>> StreamOffsets = new Dictionary<int, KeyValuePair<long, long>>();

protected readonly List<Stream> Streams = new List<Stream>();
protected int CurrentStream;
Expand Down

0 comments on commit 8b5ff0d

Please sign in to comment.