internal void AddToken(BsonToken token) { if (_parent != null) { BsonObject bo = _parent as BsonObject; if (bo != null) { bo.Add(_propertyName, token); _propertyName = null; } else { ((BsonArray)_parent).Add(token); } } else { if (token.Type != BsonType.Object && token.Type != BsonType.Array) { throw JsonWriterException.Create(this, "Error writing {0} value. BSON must start with an Object or Array.".FormatWith(CultureInfo.InvariantCulture, token.Type), null); } _parent = token; _root = token; } }
internal void AddToken(BsonToken token) { if (this._parent == null) { if (token.Type != BsonType.Object && token.Type != BsonType.Array) { throw JsonWriterException.Create(this, "Error writing {0} value. BSON must start with an Object or Array.".FormatWith(CultureInfo.InvariantCulture, token.Type), null); } this._parent = token; this._root = token; return; } BsonObject bsonObjects = this._parent as BsonObject; BsonObject bsonObjects1 = bsonObjects; if (bsonObjects == null) { ((BsonArray)this._parent).Add(token); return; } bsonObjects1.Add(this._propertyName, token); this._propertyName = null; }