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/Nitride/Contents/ByteArrayBinaryContent.cs

27 lines
648 B
C#
Raw Normal View History

2021-09-07 05:15:45 +00:00
using System;
using System.IO;
namespace 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);
}
}
}