forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHtmlString.cs
More file actions
35 lines (30 loc) · 725 Bytes
/
Copy pathHtmlString.cs
File metadata and controls
35 lines (30 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Globalization;
using System.IO;
namespace ServiceStack.Html
{
public class HelperResult : IHtmlString, System.Web.IHtmlString
{
private readonly Action<TextWriter> action;
public HelperResult(Action<TextWriter> action)
{
this.action = action ?? throw new ArgumentNullException(nameof(action), "The action parameter cannot be null.");
}
public string ToHtmlString()
{
return this.ToString();
}
public override string ToString()
{
using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
{
this.action(stringWriter);
return stringWriter.ToString();
}
}
public void WriteTo(TextWriter writer)
{
this.action(writer);
}
}
}