-
-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathHtmlConfig.cs
118 lines (103 loc) · 3.45 KB
/
HtmlConfig.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace KellermanSoftware.CompareNetObjects
{
/// <summary>
/// Config object for HtmlReport
/// </summary>
public class HtmlConfig
{
/// <summary>
/// The header value of the Bread Crumb column
/// </summary>
public string BreadCrumbColumName { get; set; }
/// <summary>
/// The header value of the Expected column
/// </summary>
public string ExpectedColumnName { get; set; }
/// <summary>
/// The header value of the Actual column
/// </summary>
public string ActualColumnName { get; set; }
/// <summary>
/// If true, the output will be complete html, if false, it will just be the table
/// </summary>
public bool GenerateFullHtml { get; set; }
/// <summary>
/// Setting this will overwrite the default html header (html, head, body tags)
/// </summary>
public string HtmlHeader
{
get { return _htmlHeader.Replace("%TITLE%", HtmlTitle).Replace("%CSS%", Style); }
set { _htmlHeader = value; }
}
/// <summary>
/// Setting this will overwrite the default html footer (closing body, html tags)
/// </summary>
public string HtmlFooter { get; set; }
/// <summary>
/// The title of the page - only visible if GenerateFullHtml == true
/// </summary>
public string HtmlTitle { get; set; }
/// <summary>
/// The CSS Style of the page - only used if the GenerateFullHtml == true
/// </summary>
public string Style { get; set; }
private string _htmlHeader;
/// <summary>
/// Default constructor, sets default values
/// </summary>
public HtmlConfig()
{
// set all the defaults
BreadCrumbColumName = "Bread Crumb";
ExpectedColumnName = "Expected";
ActualColumnName = "Actual";
GenerateFullHtml = false;
HtmlTitle = "Document";
_htmlHeader = _header;
HtmlFooter = _footer;
Style = _css;
}
/// <summary>
/// Appends to the existing Style value
/// </summary>
/// <param name="css">Any css to append</param>
public void IncludeCustomCSS(string css)
{
Style += css;
}
/// <summary>
/// Replaces the existing Style value
/// </summary>
/// <param name="css">Any css to use</param>
public void ReplaceCSS(string css)
{
Style = css;
}
private const string _header = @"<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
<meta http-equiv=""X-UA-Compatible"" content=""ie=edge"">
<title>%TITLE%</title>
<style>
%CSS%
</style>
</head>
<body>
";
private const string _footer = @"</body>
</html>";
private const string _css = @"
//.diff-crumb {background: gray;}
.diff-table tr:nth-child(odd) { background-color:#eee; }
.diff-table tr:nth-child(even) { background-color:#fff; }
//.diff-expected {color: red;}
.diff-actual {color:red;}
";
}
}