-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathCommonExtensions.cs
More file actions
33 lines (28 loc) · 884 Bytes
/
CommonExtensions.cs
File metadata and controls
33 lines (28 loc) · 884 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
using System.Globalization;
using System.Text.RegularExpressions;
using System.Web.Mvc;
namespace JavaScriptEngineSwitcher.Sample.AspNet4.Mvc4.Infrastructure.Helpers
{
public static class CommonExtensions
{
private static readonly HelperConstants _constants = new HelperConstants();
public static HelperConstants Constants(this HtmlHelper htmlHelper)
{
return _constants;
}
public static MvcHtmlString EncodedReplace(this HtmlHelper htmlHelper, string input,
string pattern, string replacement)
{
return new MvcHtmlString(Regex.Replace(htmlHelper.Encode(input), pattern, replacement));
}
internal static string CreateSubIndexName(this HtmlHelper htmlHelper, string prefix, int index)
{
string name = prefix;
if (index >= 0)
{
name = string.Format(CultureInfo.InvariantCulture, "{0}[{1}]", prefix, index);
}
return name;
}
}
}