using System;
namespace Apewer.Web
{
/// 表示 API 行为结果,主体为文本。
public class TextResult : BytesResult
{
string _text;
/// Body 文本。
public virtual string Text { get => _text; set => SetText(value); }
/// Body 字节数组。
public override byte[] Bytes { get => base.Bytes; set => throw new NotSupportedException(); }
/// 创建结果实例。
public TextResult(string text, string contentType = "text/plain") : base(null, contentType) => SetText(text);
/// 创建结果实例。
public TextResult(int status, string text, string contentType = "text/plain") : base(status, null, contentType) => SetText(text);
void SetText(string text)
{
_text = text;
base.Bytes = text.Bytes();
}
}
}