blob: 30dcb20515d14f620d476abbbd0a5458b0f1d456 (
plain)
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
36
37
38
39
40
|
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Globalization;
using System.IO;
namespace System.Web.WebPages
{
public class HelperResult : IHtmlString
{
private readonly Action<TextWriter> _action;
public HelperResult(Action<TextWriter> action)
{
if (action == null)
{
throw new ArgumentNullException("action");
}
_action = action;
}
public string ToHtmlString()
{
return ToString();
}
public override string ToString()
{
using (var writer = new StringWriter(CultureInfo.InvariantCulture))
{
_action(writer);
return writer.ToString();
}
}
public void WriteTo(TextWriter writer)
{
_action(writer);
}
}
}
|