|
|
@ -1,6 +1,4 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Text; |
|
|
|
|
|
|
|
namespace Apewer.Web |
|
|
|
{ |
|
|
@ -9,11 +7,25 @@ namespace Apewer.Web |
|
|
|
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(text.Bytes(), contentType) { } |
|
|
|
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, text.Bytes(), contentType) { } |
|
|
|
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(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|