Skip to content

Commit

Permalink
Merge pull request #122 from Numpsy/doc_comments
Browse files Browse the repository at this point in the history
Add doc comments to StreamDecorator
  • Loading branch information
ironfede authored Aug 6, 2024
2 parents cac87ec + 4ba2a94 commit 1da99f6
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions sources/OpenMcdf.Extensions/StreamDecorator.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,56 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace OpenMcdf.Extensions
{
/// <summary>
/// A wrapper class to present a <see cref="CFStream"/> as a <see cref="Stream"/>.
/// </summary>
public class StreamDecorator : Stream
{
private CFStream cfStream;
private long position = 0;

/// <summary>
/// Create a new <see cref="StreamDecorator"/> for the specified <seealso cref="CFStream"/>.
/// </summary>
/// <param name="cfstream">The <see cref="CFStream"/> being wrapped.</param>
public StreamDecorator(CFStream cfstream)
{
this.cfStream = cfstream;
}

/// <inheritdoc/>
public override bool CanRead
{
get { return true; }
}

/// <inheritdoc/>
public override bool CanSeek
{
get { return true; }
}

/// <inheritdoc/>
public override bool CanWrite
{
get { return true; }
}

/// <inheritdoc/>
public override void Flush()
{
// nothing to do;
}

/// <inheritdoc/>
public override long Length
{
get { return cfStream.Size; }
}

/// <inheritdoc/>
public override long Position
{
get
Expand All @@ -52,6 +63,7 @@ public override long Position
}
}

/// <inheritdoc/>
public override int Read(byte[] buffer, int offset, int count)
{
if (count > buffer.Length)
Expand All @@ -71,6 +83,7 @@ public override int Read(byte[] buffer, int offset, int count)
return count;
}

/// <inheritdoc/>
public override long Seek(long offset, SeekOrigin origin)
{
switch (origin)
Expand All @@ -91,17 +104,20 @@ public override long Seek(long offset, SeekOrigin origin)
return position;
}

/// <inheritdoc/>
public override void SetLength(long value)
{
this.cfStream.Resize(value);
}

/// <inheritdoc/>
public override void Write(byte[] buffer, int offset, int count)
{
this.cfStream.Write(buffer, position, offset, count);
position += count;
}

/// <inheritdoc/>
public override void Close()
{
// Do nothing
Expand Down

0 comments on commit 1da99f6

Please sign in to comment.