forked from mausch/QuartzNetWebConsole
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpers.vb
More file actions
48 lines (41 loc) · 1.57 KB
/
Helpers.vb
File metadata and controls
48 lines (41 loc) · 1.57 KB
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
Imports MiniMVC
Public Module Helpers
Public Function SimpleForm(action As String, button As String) As XElement
Return _
<form method="post" action=<%= action %>>
<input type="submit" value=<%= button %>/>
</form>
End Function
Public ReadOnly Stylesheet As XElement = <link rel="stylesheet" type="text/css" href="static.ashx?r=styles.css&t=text%2Fcss"/>
Public Function YesNo(b As Boolean) As String
Return If(b, "Yes", "No")
End Function
Public Function KV(Of K, V)(key As K, value As V) As KeyValuePair(Of K, V)
Return New KeyValuePair(Of K, V)(key, value)
End Function
Public Sub StripeTrs(xml As XElement)
For Each table In xml...<table>
Dim t = table
Dim trs = From x In t...<tr>
trs = trs.Skip(1).WhereOdd()
For Each tr In trs
Dim clas = tr.Attribute("class")
If clas IsNot Nothing Then
clas.SetValue(clas.Value + " " + "alt")
Else
tr.Add(New XAttribute("class", "alt"))
End If
Next
Next
End Sub
Public Function XHTML(e As XElement) As XDocument
StripeTrs(e)
Return e.MakeHTML5Doc()
End Function
Public Function IfNullable(Of T)(value As Boolean?, ifNull As T, ifTrue As T, ifFalse As T) As T
If Not value.HasValue Then
Return ifNull
End If
Return If(value.Value, ifTrue, ifFalse)
End Function
End Module