You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using System;
namespace Apewer.Web {
/// <summary>表示 API 行为结果,主体为文本。</summary>
public class TextResult : BytesResult {
string _text;
/// <summary>Body 文本。</summary>
public virtual string Text { get => _text; set => SetText(value); }
/// <summary>Body 字节数组。</summary>
public override byte[] Bytes { get => base.Bytes; set => throw new NotSupportedException(); }
/// <summary>创建结果实例。</summary>
public TextResult(string text, string contentType = "text/plain") : base(null, contentType) => SetText(text);
/// <summary>创建结果实例。</summary>
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(); }
}
}
|