File tree 6 files changed +25
-10
lines changed
6 files changed +25
-10
lines changed Original file line number Diff line number Diff line change @@ -290,7 +290,7 @@ public override void WriteEndArray()
290
290
_bsonStream . WriteByte ( 0 ) ;
291
291
BackpatchSize ( ) ; // size of document
292
292
293
- _context = _context . ParentContext ;
293
+ _context = _context . PopContext ( ) ;
294
294
State = GetNextState ( ) ;
295
295
}
296
296
@@ -313,7 +313,7 @@ public override void WriteEndDocument()
313
313
_bsonStream . WriteByte ( 0 ) ;
314
314
BackpatchSize ( ) ; // size of document
315
315
316
- _context = _context . ParentContext ;
316
+ _context = _context . PopContext ( ) ;
317
317
if ( _context == null )
318
318
{
319
319
State = BsonWriterState . Done ;
@@ -323,7 +323,7 @@ public override void WriteEndDocument()
323
323
if ( _context . ContextType == ContextType . JavaScriptWithScope )
324
324
{
325
325
BackpatchSize ( ) ; // size of the JavaScript with scope value
326
- _context = _context . ParentContext ;
326
+ _context = _context . PopContext ( ) ;
327
327
}
328
328
State = GetNextState ( ) ;
329
329
}
Original file line number Diff line number Diff line change @@ -55,5 +55,10 @@ internal int Index
55
55
get { return _index ; }
56
56
set { _index = value ; }
57
57
}
58
+
59
+ internal BsonBinaryWriterContext PopContext ( )
60
+ {
61
+ return _parentContext ;
62
+ }
58
63
}
59
64
}
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ public override void WriteEndArray()
195
195
196
196
base . WriteEndArray ( ) ;
197
197
var array = _context . Array ;
198
- _context = _context . ParentContext ;
198
+ _context = _context . PopContext ( ) ;
199
199
WriteValue ( array ) ;
200
200
State = GetNextState ( ) ;
201
201
}
@@ -219,15 +219,15 @@ public override void WriteEndDocument()
219
219
if ( _context . ContextType == ContextType . ScopeDocument )
220
220
{
221
221
var scope = _context . Document ;
222
- _context = _context . ParentContext ;
222
+ _context = _context . PopContext ( ) ;
223
223
var code = _context . Code ;
224
- _context = _context . ParentContext ;
224
+ _context = _context . PopContext ( ) ;
225
225
WriteValue ( new BsonJavaScriptWithScope ( code , scope ) ) ;
226
226
}
227
227
else
228
228
{
229
229
var document = _context . Document ;
230
- _context = _context . ParentContext ;
230
+ _context = _context . PopContext ( ) ;
231
231
if ( _context != null )
232
232
{
233
233
WriteValue ( document ) ;
Original file line number Diff line number Diff line change @@ -87,5 +87,10 @@ internal string Code
87
87
{
88
88
get { return _code ; }
89
89
}
90
+
91
+ internal BsonDocumentWriterContext PopContext ( )
92
+ {
93
+ return _parentContext ;
94
+ }
90
95
}
91
96
}
Original file line number Diff line number Diff line change @@ -312,7 +312,7 @@ public override void WriteEndArray()
312
312
base . WriteEndArray ( ) ;
313
313
_textWriter . Write ( "]" ) ;
314
314
315
- _context = _context . ParentContext ;
315
+ _context = _context . PopContext ( ) ;
316
316
State = GetNextState ( ) ;
317
317
}
318
318
@@ -344,12 +344,12 @@ public override void WriteEndDocument()
344
344
345
345
if ( _context . ContextType == ContextType . ScopeDocument )
346
346
{
347
- _context = _context . ParentContext ;
347
+ _context = _context . PopContext ( ) ;
348
348
WriteEndDocument ( ) ;
349
349
}
350
350
else
351
351
{
352
- _context = _context . ParentContext ;
352
+ _context = _context . PopContext ( ) ;
353
353
}
354
354
355
355
if ( _context == null )
Original file line number Diff line number Diff line change @@ -52,5 +52,10 @@ internal bool HasElements
52
52
get { return _hasElements ; }
53
53
set { _hasElements = value ; }
54
54
}
55
+
56
+ internal JsonWriterContext PopContext ( )
57
+ {
58
+ return _parentContext ;
59
+ }
55
60
}
56
61
}
You can’t perform that action at this time.
0 commit comments