// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
namespace WixToolset.Dtf.Compression
{
using System;
using System.Collections.Generic;
using System.Text;
///
/// Contains the data reported in an archive progress event.
///
public class ArchiveProgressEventArgs : EventArgs
{
private ArchiveProgressType progressType;
private string currentFileName;
private int currentFileNumber;
private int totalFiles;
private long currentFileBytesProcessed;
private long currentFileTotalBytes;
private string currentArchiveName;
private short currentArchiveNumber;
private short totalArchives;
private long currentArchiveBytesProcessed;
private long currentArchiveTotalBytes;
private long fileBytesProcessed;
private long totalFileBytes;
///
/// Creates a new ArchiveProgressEventArgs object from specified event parameters.
///
/// type of status message
/// name of the file being processed
/// number of the current file being processed
/// total number of files to be processed
/// number of bytes processed so far when compressing or extracting a file
/// total number of bytes in the current file
/// name of the current Archive
/// current Archive number, when processing a chained set of Archives
/// total number of Archives in a chained set
/// number of compressed bytes processed so far during an extraction
/// total number of compressed bytes to be processed during an extraction
/// number of uncompressed file bytes processed so far
/// total number of uncompressed file bytes to be processed
public ArchiveProgressEventArgs(
ArchiveProgressType progressType,
string currentFileName,
int currentFileNumber,
int totalFiles,
long currentFileBytesProcessed,
long currentFileTotalBytes,
string currentArchiveName,
int currentArchiveNumber,
int totalArchives,
long currentArchiveBytesProcessed,
long currentArchiveTotalBytes,
long fileBytesProcessed,
long totalFileBytes)
{
this.progressType = progressType;
this.currentFileName = currentFileName;
this.currentFileNumber = currentFileNumber;
this.totalFiles = totalFiles;
this.currentFileBytesProcessed = currentFileBytesProcessed;
this.currentFileTotalBytes = currentFileTotalBytes;
this.currentArchiveName = currentArchiveName;
this.currentArchiveNumber = (short) currentArchiveNumber;
this.totalArchives = (short) totalArchives;
this.currentArchiveBytesProcessed = currentArchiveBytesProcessed;
this.currentArchiveTotalBytes = currentArchiveTotalBytes;
this.fileBytesProcessed = fileBytesProcessed;
this.totalFileBytes = totalFileBytes;
}
///
/// Gets the type of status message.
///
/// A value indicating what type of progress event occurred.
///
/// The handler may choose to ignore some types of progress events.
/// For example, if the handler will only list each file as it is
/// compressed/extracted, it can ignore events that
/// are not of type .
///
public ArchiveProgressType ProgressType
{
get
{
return this.progressType;
}
}
///
/// Gets the name of the file being processed. (The name of the file within the Archive; not the external
/// file path.) Also includes the internal path of the file, if any. Valid for
/// , ,
/// and messages.
///
/// The name of the file currently being processed, or null if processing
/// is currently at the stream or archive level.
public string CurrentFileName
{
get
{
return this.currentFileName;
}
}
///
/// Gets the number of the current file being processed. The first file is number 0, and the last file
/// is -1. Valid for ,
/// , and messages.
///
/// The number of the file currently being processed, or the most recent
/// file processed if processing is currently at the stream or archive level.
public int CurrentFileNumber
{
get
{
return this.currentFileNumber;
}
}
///
/// Gets the total number of files to be processed. Valid for all message types.
///
/// The total number of files to be processed that are known so far.
public int TotalFiles
{
get
{
return this.totalFiles;
}
}
///
/// Gets the number of bytes processed so far when compressing or extracting a file. Valid for
/// , ,
/// and messages.
///
/// The number of uncompressed bytes processed so far for the current file,
/// or 0 if processing is currently at the stream or archive level.
public long CurrentFileBytesProcessed
{
get
{
return this.currentFileBytesProcessed;
}
}
///
/// Gets the total number of bytes in the current file. Valid for ,
/// , and messages.
///
/// The uncompressed size of the current file being processed,
/// or 0 if processing is currently at the stream or archive level.
public long CurrentFileTotalBytes
{
get
{
return this.currentFileTotalBytes;
}
}
///
/// Gets the name of the current archive. Not necessarily the name of the archive on disk.
/// Valid for all message types.
///
/// The name of the current archive, or an empty string if no name was specified.
public string CurrentArchiveName
{
get
{
return this.currentArchiveName;
}
}
///
/// Gets the current archive number, when processing a chained set of archives. Valid for all message types.
///
/// The number of the current archive.
/// The first archive is number 0, and the last archive is
/// -1.
public int CurrentArchiveNumber
{
get
{
return this.currentArchiveNumber;
}
}
///
/// Gets the total number of known archives in a chained set. Valid for all message types.
///
/// The total number of known archives in a chained set.
///
/// When using the compression option to auto-split into multiple archives based on data size,
/// this value will not be accurate until the end.
///
public int TotalArchives
{
get
{
return this.totalArchives;
}
}
///
/// Gets the number of compressed bytes processed so far during extraction
/// of the current archive. Valid for all extraction messages.
///
/// The number of compressed bytes processed so far during extraction
/// of the current archive.
public long CurrentArchiveBytesProcessed
{
get
{
return this.currentArchiveBytesProcessed;
}
}
///
/// Gets the total number of compressed bytes to be processed during extraction
/// of the current archive. Valid for all extraction messages.
///
/// The total number of compressed bytes to be processed during extraction
/// of the current archive.
public long CurrentArchiveTotalBytes
{
get
{
return this.currentArchiveTotalBytes;
}
}
///
/// Gets the number of uncompressed bytes processed so far among all files. Valid for all message types.
///
/// The number of uncompressed file bytes processed so far among all files.
///
/// When compared to , this can be used as a measure of overall progress.
///
public long FileBytesProcessed
{
get
{
return this.fileBytesProcessed;
}
}
///
/// Gets the total number of uncompressed file bytes to be processed. Valid for all message types.
///
/// The total number of uncompressed bytes to be processed among all files.
public long TotalFileBytes
{
get
{
return this.totalFileBytes;
}
}
#if DEBUG
///
/// Creates a string representation of the progress event.
///
/// a listing of all event parameters and values
public override string ToString()
{
string formatString =
"{0}\n" +
"\t CurrentFileName = {1}\n" +
"\t CurrentFileNumber = {2}\n" +
"\t TotalFiles = {3}\n" +
"\t CurrentFileBytesProcessed = {4}\n" +
"\t CurrentFileTotalBytes = {5}\n" +
"\t CurrentArchiveName = {6}\n" +
"\t CurrentArchiveNumber = {7}\n" +
"\t TotalArchives = {8}\n" +
"\t CurrentArchiveBytesProcessed = {9}\n" +
"\t CurrentArchiveTotalBytes = {10}\n" +
"\t FileBytesProcessed = {11}\n" +
"\t TotalFileBytes = {12}\n";
return String.Format(
System.Globalization.CultureInfo.InvariantCulture,
formatString,
this.ProgressType,
this.CurrentFileName,
this.CurrentFileNumber,
this.TotalFiles,
this.CurrentFileBytesProcessed,
this.CurrentFileTotalBytes,
this.CurrentArchiveName,
this.CurrentArchiveNumber,
this.TotalArchives,
this.CurrentArchiveBytesProcessed,
this.CurrentArchiveTotalBytes,
this.FileBytesProcessed,
this.TotalFileBytes);
}
#endif
}
}