forked from RickStrahl/Westwind.Scripting
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRawString.cs
More file actions
71 lines (59 loc) · 1.71 KB
/
Copy pathRawString.cs
File metadata and controls
71 lines (59 loc) · 1.71 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System.IO;
using System;
namespace Westwind.Scripting
{
/// <summary>
/// Marker interface
/// </summary>
public interface IRawString
{
string ToString();
}
/// <summary>
/// String container that indicates that this string
/// should never be Html Encoded.
/// </summary>
public class RawString : IRawString
{
/// <summary>
/// The raw string value that's been assigned.
/// Alternately retrieve with .ToString()
/// </summary>
private string Value { get; set; }
public static RawString Empty => new RawString(string.Empty);
public RawString()
{ }
public RawString(string value)
{
Value = value;
}
public RawString(object value)
{
if (value is not null)
Value = value.ToString();
}
public override string ToString()
{
return Value;
}
/// <summary>
/// Returns a raw string (same as new RawString() but
/// easier to use in code {{ RawString.Raw() }}
///
/// Functions can return IRawString to
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static RawString Raw(string value) => new RawString(value);
/// <summary>
/// Returns a raw string (same as new RawString() but
/// easier to use in code {{ RawString.Raw() }}
///
/// Functions can return IRawString to
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static RawString Raw(object value) => new RawString(value);
}
}