-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from gardebring/master
Add new event handler to allow tracking of progress of extraction progress for individual entry
- Loading branch information
Showing
6 changed files
with
67 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
using System; | ||
using SharpCompress.Readers; | ||
|
||
namespace SharpCompress.Common | ||
{ | ||
public class ReaderExtractionEventArgs<T> : EventArgs | ||
{ | ||
internal ReaderExtractionEventArgs(T entry) | ||
internal ReaderExtractionEventArgs(T entry, ReaderProgress readerProgress = null) | ||
{ | ||
Item = entry; | ||
ReaderProgress = readerProgress; | ||
} | ||
|
||
public T Item { get; private set; } | ||
public ReaderProgress ReaderProgress { get; private set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
| ||
|
||
using System; | ||
using SharpCompress.Common; | ||
|
||
namespace SharpCompress.Readers | ||
{ | ||
public class ReaderProgress | ||
{ | ||
private readonly IEntry _entry; | ||
public long BytesTransferred { get; private set; } | ||
public int Iterations { get; private set; } | ||
|
||
public int PercentageRead => (int)Math.Round(PercentageReadExact); | ||
public double PercentageReadExact => (float)BytesTransferred / _entry.Size * 100; | ||
|
||
public ReaderProgress(IEntry entry, long bytesTransferred, int iterations) | ||
{ | ||
_entry = entry; | ||
BytesTransferred = bytesTransferred; | ||
Iterations = iterations; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters