1 | #Region "Microsoft.VisualBasic::c73a7d5135f35a0d72477ae6565af3e6, Microsoft.VisualBasic.Core\Text\Xml\HtmlBuilder.vb" |
2 | |
3 | ' Author: |
4 | ' |
5 | ' asuka (amethyst.asuka@gcmodeller.org) |
6 | ' xie (genetics@smrucc.org) |
7 | ' xieguigang (xie.guigang@live.com) |
8 | ' |
9 | ' Copyright (c) 2018 GPL3 Licensed |
10 | ' |
11 | ' |
12 | ' GNU GENERAL PUBLIC LICENSE (GPL3) |
13 | ' |
14 | ' |
15 | ' This program is free software: you can redistribute it and/or modify |
16 | ' it under the terms of the GNU General Public License as published by |
17 | ' the Free Software Foundation, either version 3 of the License, or |
18 | ' (at your option) any later version. |
19 | ' |
20 | ' This program is distributed in the hope that it will be useful, |
21 | ' but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | ' GNU General Public License for more details. |
24 | ' |
25 | ' You should have received a copy of the GNU General Public License |
26 | ' along with this program. If not, see <http://www.gnu.org/licenses/>. |
27 | |
28 | |
29 | |
30 | ' /********************************************************************************/ |
31 | |
32 | ' Summaries: |
33 | |
34 | ' Module HtmlBuilder |
35 | ' |
36 | ' Function: AppendLine, sprintf |
37 | ' |
38 | ' |
39 | ' /********************************************************************************/ |
40 | |
41 | #End Region |
42 | |
43 | Imports System.Runtime.CompilerServices |
44 | Imports System.Text |
45 | Imports Microsoft.VisualBasic.Language.C |
46 | |
47 | Namespace Text.Xml |
48 | |
49 | Public Module HtmlBuilder |
50 | |
51 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
52 | <Extension> |
53 | Public Function sprintf(format As XElement, ParamArray args As Object()) As String |
54 | Return CLangStringFormatProvider.sprintf(format.ToString, args) |
55 | End Function |
56 | |
57 | ''' <summary> |
58 | ''' Appends a copy of the specified string followed by the default line terminator |
59 | ''' to the end of the current <see cref="StringBuilder"/> object. |
60 | ''' </summary> |
61 | ''' <param name="sb"></param> |
62 | ''' <param name="html">The html string to append.</param> |
63 | ''' <returns></returns> |
64 | ''' <remarks> |
65 | ''' A reference to this instance after the append operation has completed. |
66 | ''' </remarks> |
67 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
68 | <Extension> |
69 | Public Function AppendLine(sb As StringBuilder, html As XElement, ParamArray args As Object()) As StringBuilder |
70 | If args.IsNullOrEmpty Then |
71 | Return sb.AppendLine(html.ToString) |
72 | Else |
73 | Return sb.AppendLine(CLangStringFormatProvider.sprintf(html.ToString, args)) |
74 | End If |
75 | End Function |
76 | End Module |
77 | End Namespace |