Skip to content

Commit

Permalink
code clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
thoemmi committed Jun 5, 2016
1 parent c6738f8 commit b202035
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 33 deletions.
8 changes: 7 additions & 1 deletion 7Zip4Powershell/7Zip4Powershell.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="JetBrains.Annotations, Version=10.1.4.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
<HintPath>..\packages\JetBrains.Annotations.10.1.4\lib\net20\JetBrains.Annotations.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SevenZipSharp">
<HintPath>..\packages\SevenZipSharp.0.64\lib\SevenZipSharp.dll</HintPath>
</Reference>
Expand All @@ -63,7 +67,9 @@
</ItemGroup>
<ItemGroup>
<None Include="7Zip4PowerShell.psd1" />
<None Include="packages.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="PostBuild.targets" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion 7Zip4Powershell/7Zip4Powershell.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<tags>powershell 7zip 7-zip zip archive extract compress</tags>
</metadata>
<files>
<file src="bin\$configuration$\*.dll" target="tools"/>
<file src="bin\$configuration$\*.dll" target="tools" exclude="**\JetBrains.*"/>
<file src="bin\$configuration$\*.psd1" target="tools"/>
</files>
</package>
14 changes: 5 additions & 9 deletions 7Zip4Powershell/Compress7Zip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
using System.IO;
using System.Linq;
using System.Management.Automation;
using JetBrains.Annotations;
using SevenZip;

namespace SevenZip4PowerShell {
[Cmdlet(VerbsData.Compress, "7Zip")]
[PublicAPI]
public class Compress7Zip : ThreadedCmdlet {
public Compress7Zip() {
Format = OutArchiveFormat.SevenZip;
CompressionLevel = CompressionLevel.Normal;
CompressionMethod = CompressionMethod.Ppmd;
}

[Parameter(Position = 0, Mandatory = true, HelpMessage = "The full file name of the archive")]
[ValidateNotNullOrEmpty]
public string ArchiveFileName { get; set; }
Expand All @@ -28,13 +24,13 @@ public Compress7Zip() {
private List<string> _directoryOrFilesFromPipeline;

[Parameter]
public OutArchiveFormat Format { get; set; }
public OutArchiveFormat Format { get; set; } = OutArchiveFormat.SevenZip;

[Parameter]
public CompressionLevel CompressionLevel { get; set; }
public CompressionLevel CompressionLevel { get; set; } = CompressionLevel.Normal;

[Parameter]
public CompressionMethod CompressionMethod { get; set; }
public CompressionMethod CompressionMethod { get; set; } = CompressionMethod.Ppmd;

[Parameter]
public string Password { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions 7Zip4Powershell/Expand7Zip.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.IO;
using System.Management.Automation;
using JetBrains.Annotations;
using SevenZip;

namespace SevenZip4PowerShell {
[Cmdlet(VerbsData.Expand, "7Zip")]
[PublicAPI]
public class Expand7Zip : ThreadedCmdlet {
[Parameter(Position = 0, Mandatory = true, HelpMessage = "The full file name of the archive")]
[ValidateNotNullOrEmpty]
Expand Down
4 changes: 3 additions & 1 deletion 7Zip4Powershell/Get7Zip.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.IO;
using System.Management.Automation;
using JetBrains.Annotations;
using SevenZip;

namespace SevenZip4PowerShell {
[Cmdlet(VerbsCommon.Get, "7Zip")]
[PublicAPI]
public class Get7Zip : PSCmdlet {
[Parameter(Position = 0, Mandatory = true, HelpMessage = "The full file name of the archive")]
[ValidateNotNullOrEmpty]
Expand All @@ -18,7 +20,7 @@ protected override void BeginProcessing() {

protected override void ProcessRecord() {
var archiveFileName =
new FileInfo(Path.Combine(this.SessionState.Path.CurrentFileSystemLocation.Path, this.ArchiveFileName)).FullName;
new FileInfo(Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, this.ArchiveFileName)).FullName;

WriteVerbose($"Getting archive data {archiveFileName}");

Expand Down
24 changes: 3 additions & 21 deletions 7Zip4Powershell/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,10 @@ namespace SevenZip4PowerShell
{
internal class Utils
{
public static string SevenZipLibraryPath
{
get
{
return Path.Combine(AssemblyPath, SevenZipLibraryName);
}
}
public static string SevenZipLibraryPath => Path.Combine(AssemblyPath, SevenZipLibraryName);

public static string AssemblyPath
{
get
{
return Path.GetDirectoryName(typeof(Utils).Assembly.Location);
}
}
private static string AssemblyPath => Path.GetDirectoryName(typeof(Utils).Assembly.Location);

private static string SevenZipLibraryName
{
get
{
return Environment.Is64BitProcess ? "7z64.dll" : "7z.dll";
}
}
private static string SevenZipLibraryName => Environment.Is64BitProcess ? "7z64.dll" : "7z.dll";
}
}
2 changes: 2 additions & 0 deletions 7Zip4Powershell/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="GitVersionTask" version="3.4.1" targetFramework="net45" developmentDependency="true" />
<package id="JetBrains.Annotations" version="10.1.4" targetFramework="net45" developmentDependency="true"/>
<package id="SevenZipSharp" version="0.64" targetFramework="net40" />
<package id="System.Runtime" version="4.0.0" targetFramework="net45" developmentDependency="true"/>
</packages>

0 comments on commit b202035

Please sign in to comment.