-
-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
325 additions
and
118 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,55 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace Palmmedia.ReportGenerator.Reporting.History | ||
{ | ||
/// <summary> | ||
/// Default implementation of <see cref="IHistoryStorage"/> based on file system. | ||
/// </summary> | ||
internal class FileHistoryStorage : IHistoryStorage | ||
{ | ||
/// <summary> | ||
/// The history directory. | ||
/// </summary> | ||
private readonly string historyDirectory; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FileHistoryStorage"/> class. | ||
/// </summary> | ||
/// <param name="historyDirectory">The history directory.</param> | ||
public FileHistoryStorage(string historyDirectory) | ||
{ | ||
this.historyDirectory = historyDirectory; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the history file paths. | ||
/// </summary> | ||
/// <returns> | ||
/// The history file paths. | ||
/// </returns> | ||
public IEnumerable<string> GetHistoryFilePaths() => Directory.EnumerateFiles(this.historyDirectory, "*_CoverageHistory.xml"); | ||
|
||
/// <summary> | ||
/// Loads the given file. | ||
/// </summary> | ||
/// <param name="filePath">The file path.</param> | ||
/// <returns> | ||
/// The file as stream. | ||
/// </returns> | ||
public Stream LoadFile(string filePath) => File.OpenRead(filePath); | ||
|
||
/// <summary> | ||
/// Saves the file with the given name. | ||
/// </summary> | ||
/// <param name="stream">The stream containing the file content.</param> | ||
/// <param name="fileName">Name of the file.</param> | ||
public void SaveFile(Stream stream, string fileName) | ||
{ | ||
using (var output = File.OpenWrite(Path.Combine(this.historyDirectory, fileName))) | ||
{ | ||
stream.CopyTo(output); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.