/
ScriptConfig.cs
59 lines (55 loc) · 2.51 KB
/
ScriptConfig.cs
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
using System;
using System.Collections.Generic;
using System.Globalization;
using ServiceStack.IO;
using ServiceStack.Text;
namespace ServiceStack.Script
{
public static class ScriptConfig
{
/// <summary>
/// Rethrow fatal exceptions thrown on incorrect API usage
/// </summary>
public static HashSet<Type> FatalExceptions { get; set; } = new HashSet<Type>
{
typeof(NotSupportedException),
typeof(NotImplementedException),
typeof(StackOverflowException),
};
public static HashSet<Type> CaptureAndEvaluateExceptionsToNull { get; set; } = new HashSet<Type>
{
typeof(NullReferenceException),
typeof(ArgumentNullException),
};
public static CultureInfo DefaultCulture { get; set; } //Uses CurrentCulture by default
public static string DefaultDateFormat { get; set; } = "yyyy-MM-dd";
public static string DefaultDateTimeFormat { get; set; } = "u";
public static string DefaultTimeFormat { get; set; } = @"h\:mm\:ss";
public static TimeSpan DefaultFileCacheExpiry { get; set; } =TimeSpan.FromMinutes(1);
public static TimeSpan DefaultUrlCacheExpiry { get; set; } =TimeSpan.FromMinutes(1);
public static string DefaultIndent { get; set; } = "\t";
public static string DefaultNewLine { get; set; } = Environment.NewLine;
public static string DefaultJsConfig { get; set; } = "excludetypeinfo";
public static StringComparison DefaultStringComparison { get; set; } = StringComparison.Ordinal;
public static string DefaultTableClassName { get; set; } = "table";
public static string DefaultErrorClassName { get; set; } = "alert alert-danger";
public static bool AllowUnixPipeSyntax { get; set; } = true;
public static bool AllowAssignmentExpressions { get; set; } = true;
public static ParseRealNumber ParseRealNumber = numLiteral => numLiteral.ParseDouble();
public static CultureInfo CreateCulture()
{
var culture = DefaultCulture;
if (culture == null)
{
culture = CultureInfo.CurrentCulture;
}
if (Equals(culture, CultureInfo.InvariantCulture))
{
culture = (CultureInfo) culture.Clone();
culture.NumberFormat.CurrencySymbol = "$";
}
return culture;
}
}
public delegate object ParseRealNumber(ReadOnlySpan<char> numLiteral);
}