add some documentation

This commit is contained in:
schedpas
2020-07-16 08:30:41 +02:00
parent 30afb0c5f8
commit c136c9f180
2 changed files with 46 additions and 0 deletions

View File

@@ -29,6 +29,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Pilz.Cryptography.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.VisualBasic" /> <Reference Include="Microsoft.VisualBasic" />

View File

@@ -14,17 +14,32 @@ namespace Pilz.IO
[JsonProperty("CompressedFiles")] [JsonProperty("CompressedFiles")]
private readonly Dictionary<string, byte[]> compressedFiles = new Dictionary<string, byte[]>(); private readonly Dictionary<string, byte[]> compressedFiles = new Dictionary<string, byte[]>();
/// <summary>
/// Returns the names of all embedded files.
/// </summary>
[JsonIgnore] [JsonIgnore]
public IEnumerable<string> AllFileNames public IEnumerable<string> AllFileNames
{ {
get => compressedFiles.Keys; get => compressedFiles.Keys;
} }
/// <summary>
/// Embeds a file to this container.
/// </summary>
/// <param name="fileName">The name how it should be called in this container.</param>
/// <param name="filePath">The file path to the file that should be embedded.</param>
/// <returns>Returns a <see cref="bool"/> that defines if the file as been embedded successfully.</returns>
public Task<bool> AddFileAsync(string fileName, string filePath) public Task<bool> AddFileAsync(string fileName, string filePath)
{ {
return Task.Run(() => AddFile(fileName, filePath)); return Task.Run(() => AddFile(fileName, filePath));
} }
/// <summary>
/// Embeds a file to this container.
/// </summary>
/// <param name="fileName">The name how it should be called in this container.</param>
/// <param name="filePath">The file path to the file that should be embedded.</param>
/// <returns>Returns a <see cref="bool"/> that defines if the file as been embedded successfully.</returns>
public bool AddFile(string fileName, string filePath) public bool AddFile(string fileName, string filePath)
{ {
bool success; bool success;
@@ -63,22 +78,41 @@ namespace Pilz.IO
return success; return success;
} }
/// <summary>
/// Removes a file from this container.
/// </summary>
/// <param name="fileName">The name how the file is called.</param>
public void RemoveFile(string fileName) public void RemoveFile(string fileName)
{ {
if (compressedFiles.ContainsKey(fileName)) if (compressedFiles.ContainsKey(fileName))
compressedFiles.Remove(fileName); compressedFiles.Remove(fileName);
} }
/// <summary>
/// Checks if the given file exists in this container.
/// </summary>
/// <param name="fileName">The name how the file is called.</param>
/// <returns>Returns if the given file exists in this container.</returns>
public bool HasFile(string fileName) public bool HasFile(string fileName)
{ {
return compressedFiles.ContainsKey(fileName); return compressedFiles.ContainsKey(fileName);
} }
/// <summary>
/// Gets a file from this container as stream.
/// </summary>
/// <param name="fileName">The name how the file is called.</param>
/// <returns>Returns a stream of the file with the given name.</returns>
public Task<Stream> GetStreamAsync(string fileName) public Task<Stream> GetStreamAsync(string fileName)
{ {
return Task.Run(() => GetStream(fileName)); return Task.Run(() => GetStream(fileName));
} }
/// <summary>
/// Gets a file from this container as stream.
/// </summary>
/// <param name="fileName">The name how the file is called.</param>
/// <returns>Returns a stream of the file with the given name.</returns>
public Stream GetStream(string fileName) public Stream GetStream(string fileName)
{ {
Stream decompressed = null; Stream decompressed = null;
@@ -92,11 +126,22 @@ namespace Pilz.IO
return decompressed; return decompressed;
} }
/// <summary>
/// Saves a given file to the users temp directory.
/// </summary>
/// <param name="fileName">The name how the file is called.</param>
/// <returns>Returns the file path to the temp file.</returns>
public Task<string> GetLocalFilePathAsync(string fileName) public Task<string> GetLocalFilePathAsync(string fileName)
{ {
return Task.Run(() => GetLocalFilePath(fileName)); return Task.Run(() => GetLocalFilePath(fileName));
} }
/// <summary>
/// Saves a given file to the users temp directory.
/// </summary>
/// <param name="fileName">The name how the file is called.</param>
/// <returns>Returns the file path to the temp file.</returns>
public string GetLocalFilePath(string fileName) public string GetLocalFilePath(string fileName)
{ {
string filePath = string.Empty; string filePath = string.Empty;