1 | #Region "Microsoft.VisualBasic::1e8a0583a5c4bc55557a327987fff6e5, Microsoft.VisualBasic.Core\Serialization\JSON\Formatter\Strategies\OpenBracketStrategy.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 | ' Class OpenBracketStrategy |
35 | ' |
36 | ' Properties: ForWhichCharacter |
37 | ' |
38 | ' Function: IsBeginningOfNewLineAndIndentionLevel |
39 | ' |
40 | ' Sub: Execute |
41 | ' |
42 | ' |
43 | ' /********************************************************************************/ |
44 | |
45 | #End Region |
46 | |
47 | Namespace Serialization.JSON.Formatter.Internals.Strategies |
48 | Friend NotInheritable Class OpenBracketStrategy |
49 | Implements ICharacterStrategy |
50 | Public Sub Execute(context As JsonFormatterStrategyContext) Implements ICharacterStrategy.Execute |
51 | If context.IsProcessingString Then |
52 | context.AppendCurrentChar() |
53 | Return |
54 | End If |
55 | |
56 | context.AppendCurrentChar() |
57 | context.EnterObjectScope() |
58 | |
59 | If Not IsBeginningOfNewLineAndIndentionLevel(context) Then |
60 | Return |
61 | End If |
62 | |
63 | context.BuildContextIndents() |
64 | End Sub |
65 | |
66 | Private Shared Function IsBeginningOfNewLineAndIndentionLevel(context As JsonFormatterStrategyContext) As Boolean |
67 | Return context.IsProcessingVariableAssignment OrElse (Not context.IsStart AndAlso Not context.IsInArrayScope) |
68 | End Function |
69 | |
70 | Public ReadOnly Property ForWhichCharacter() As Char Implements ICharacterStrategy.ForWhichCharacter |
71 | Get |
72 | Return "{"c |
73 | End Get |
74 | End Property |
75 | End Class |
76 | End Namespace |