/
JSLintOptions.cs
88 lines (79 loc) · 2.52 KB
/
JSLintOptions.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
85
86
87
88
namespace JSLintNet
{
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
public partial class JSLintOptions : ICloneable
{
private Dictionary<string, bool> predefinedGlobals;
/// <summary>
/// Initializes a new instance of the <see cref="JSLintOptions"/> class.
/// </summary>
public JSLintOptions()
{
this.predefinedGlobals = new Dictionary<string, bool>();
}
/// <summary>
/// Gets the predefined globals.
/// </summary>
/// <value>
/// The predefined globals.
/// </value>
/// <remarks>
/// JSLint "predef" option.
/// </remarks>
[JsonProperty("predef")]
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "JSLint option names are non words.")]
public Dictionary<string, bool> PredefinedGlobals
{
get
{
return this.predefinedGlobals;
}
}
/// <summary>
/// Creates a new object that is a copy of the current instance.
/// </summary>
/// <returns>
/// A new object that is a copy of this instance.
/// </returns>
public JSLintOptions TypedClone()
{
var clone = new JSLintOptions();
clone.predefinedGlobals = new Dictionary<string, bool>(this.predefinedGlobals);
this.CloneRoot(clone);
return clone;
}
/// <summary>
/// Creates a new object that is a copy of the current instance.
/// </summary>
/// <returns>
/// A new object that is a copy of this instance.
/// </returns>
public object Clone()
{
return this.TypedClone();
}
/// <summary>
/// Merges the specified options into this instance.
/// </summary>
/// <param name="merge">The options to merge.</param>
public void Merge(JSLintOptions merge)
{
this.MergeGlobals(merge);
this.MergeRoot(merge);
}
private void MergeGlobals(JSLintOptions merge)
{
if (merge.PredefinedGlobals == null)
{
return;
}
foreach (var global in merge.PredefinedGlobals)
{
this.predefinedGlobals[global.Key] = global.Value;
}
}
}
}