internal void RaiseValue(BSONToken value) { switch (value.Type) { case BSONTokenType.STRING: if (null != String) { String(((BSONValueToken<string>)value).Value); } break; case BSONTokenType.DOUBLE: if (null != Double) { Double(((BSONValueToken<double>)value).Value); } break; case BSONTokenType.BOOLEAN: if (null != Boolean) { Boolean(((BSONValueToken<bool>)value).Value); } break; case BSONTokenType.DATETIME: if (null != DateTime) { DateTime(((BSONValueToken<DateTime>)value).Value); } break; case BSONTokenType.INT32: if (null != Int32) { Int32(((BSONValueToken<Int32>)value).Value); } break; case BSONTokenType.INT64: if (null != Int64) { Int64(((BSONValueToken<Int64>)value).Value); } break; case BSONTokenType.NULL: if (null != Null) { Null(); } break; default: if (null != Value) { Value(value); } break; } }
private void _DocumentElement(BSONToken token, BSONTokenStream tokens, BSONWalkingEvents events) { if (BSONTokenType.END == token.Type || BSONTokenType.EOF == token.Type) { throw new BSONValidationException("Unexpected BSON token type encountered: " + token.Type); } if (BSONTokenType.DOCUMENT_START == token.Type) { events.RaiseElement(token.Name, token.Type); _Document(tokens, events, BSONTypes.DOCUMENT); } else if (BSONTokenType.ARRAY_START == token.Type) { events.RaiseElement(token.Name, token.Type); _Document(tokens, events, BSONTypes.ARRAY); } else if (BSONTokenType.CODE_WITH_SCOPE == token.Type) { events.RaiseElement(token.Name, token.Type); events.RaiseValue(token); tokens.MoveNext(); token = tokens.Current; if (BSONTokenType.END == token.Type || BSONTokenType.EOF == token.Type) { throw new BSONValidationException("Expected DOCUMENT but got: " + token.Type); } if (BSONTokenType.DOCUMENT_START == token.Type) { _Document(tokens, events, BSONTypes.DOCUMENT); } else if (BSONTokenType.ARRAY_START == token.Type) { _Document(tokens, events, BSONTypes.ARRAY); } } else { events.RaiseElement(token.Name, token.Type); events.RaiseValue(token); } }
private void _events_Value(BSONToken token) { if (BSONTokenType.BINARY == token.Type) // only supports the Binary type { _consumeValue(((BSONBinaryToken)token).Value); } }