-
Notifications
You must be signed in to change notification settings - Fork 1
/
CobaltConfiguration.cs
84 lines (65 loc) · 2.44 KB
/
CobaltConfiguration.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Collections.Generic;
using System.IO;
using System.Web;
using Cobalt.Html;
using Cobalt.Css;
namespace Cobalt {
/// <summary>
/// Holds general configuration for Cobalt
/// </summary>
public static class CobaltConfiguration {
#region Constants
internal const string CONTROL_CONTEXT_ELEMENT = "cobaltelementcontext";
#endregion
#region Methods
/// <summary>
/// Prepares Cobalt to be used with this site
/// </summary>
public static void Initialize() {
CobaltConfiguration.VerifyBrowserFile();
}
/// <summary>
/// Ensures that the browser file required is created in
/// the project
/// </summary>
public static void VerifyBrowserFile() {
//get the path
string browsers = HttpContext.Current.Server.MapPath("~/App_Browsers/");
//check the directory first
if (!Directory.Exists(browsers)) {
Directory.CreateDirectory(browsers);
}
//check for the file
string file = Path.Combine(browsers, "Cobalt.browser");
if (!File.Exists(file)) {
File.WriteAllText(file, Resources.Resources.BrowserFile);
}
}
/// <summary>
/// Registers a custom pseudo selector
/// </summary>
public static void RegisterCustomPseudoSelector(string name, Func<IEnumerable<HtmlNode>, string, IEnumerable<HtmlNode>> compare) {
CssSelectorDetail.RegisterCustomPseudoSelector(name, compare);
}
/// <summary>
/// Removes a custom pseudo selector if any for the name exists
/// </summary>
public static void UnregisterCustomPseudoSelector(string name) {
CssSelectorDetail.UnregisterCustomPseudoSelector(name);
}
/// <summary>
/// Registers a custom attribute selector
/// </summary>
public static void RegisterCustomAttributeSelector(string type, Func<string, string, bool> compare) {
CssSelectorDetail.RegisterCustomAttributeSelector(type, compare);
}
/// <summary>
/// Removes an existing custom attribute selector
/// </summary>
public static void UnregisterCustomAttributeSelector(string type) {
CssSelectorDetail.UnregisterCustomAttributeSelector(type);
}
#endregion
}
}