1 #Region "Microsoft.VisualBasic::825a83ffbbe8dddcddc7c2dc18f51d86, Microsoft.VisualBasic.Core\Serialization\JSON\Formatter\FormatterScopeState.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 FormatterScopeState
35     
36     
37     '         Enum JsonScope
38     
39     '             [Object], Array
40     
41     
42     
43     '  
44     
45     '     Properties: IsTopTypeArray, ScopeDepth
46     
47     '     Function: PopJsonType
48     
49     '     Sub: PushJsonArrayType, PushObjectContextOntoStack
50     
51     
52     ' /********************************************************************************/
53
54 #End Region
55
56 Imports System.Collections.Generic
57
58 Namespace Serialization.JSON.Formatter.Internals
59
60     Friend NotInheritable Class FormatterScopeState
61         Public Enum JsonScope
62             [Object]
63             Array
64         End Enum
65
66         ReadOnly scopeStack As New Stack(Of JsonScope)()
67
68         Public ReadOnly Property IsTopTypeArray() As Boolean
69             Get
70                 Return scopeStack.Count > 0 AndAlso scopeStack.Peek() = JsonScope.Array
71             End Get
72         End Property
73
74         Public ReadOnly Property ScopeDepth() As Integer
75             Get
76                 Return scopeStack.Count
77             End Get
78         End Property
79
80         Public Sub PushObjectContextOntoStack()
81             scopeStack.Push(JsonScope.[Object])
82         End Sub
83
84         Public Function PopJsonType() As JsonScope
85             Return scopeStack.Pop()
86         End Function
87
88         Public Sub PushJsonArrayType()
89             scopeStack.Push(JsonScope.Array)
90         End Sub
91     End Class
92 End Namespace