This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/src/MfGames.Nitride/Contents/ByteArrayBinaryContent.cs

25 lines
570 B
C#

using System;
using System.IO;
namespace MfGames.Nitride.Contents;
/// <summary>
/// Implements a purely in-memory binary content provider.
/// </summary>
public class ByteArrayBinaryContent : IBinaryContent
{
private readonly byte[] buffer;
public ByteArrayBinaryContent(byte[] buffer)
{
this.buffer = buffer ?? throw new ArgumentNullException(nameof(buffer));
}
/// <inheritdoc />
public Stream GetStream()
{
// Return a memory stream that cannot be written.
return new MemoryStream(this.buffer, false);
}
}