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/StringTextContent.cs

36 lines
761 B
C#

using System;
using System.IO;
using System.Text;
namespace MfGames.Nitride.Contents;
/// <summary>
/// Implements a pure, in-memory text content provider that uses a string
/// as the backing store.
/// </summary>
public class StringTextContent : ITextContent
{
private readonly string buffer;
public StringTextContent(StringBuilder buffer)
: this(buffer.ToString())
{
}
public StringTextContent(string buffer)
{
this.buffer = buffer ?? throw new ArgumentNullException(nameof(buffer));
}
public StringTextContent(params string[] lines)
: this(string.Join("\n", lines))
{
}
/// <inheritdoc />
public TextReader GetReader()
{
return new StringReader(this.buffer);
}
}