public void DeserializeBson(BsonDeserializingContext context)
        {
            context.BsonReader.ReadStartDocument();
            if (context.BsonReader.State == BsonReaderState.Type)
            {
                context.BsonReader.ReadBsonType();
            }
            while (context.BsonReader.State != BsonReaderState.EndOfDocument)
            {
                string name = context.BsonReader.ReadName(Utf8NameDecoder.Instance);

                if (_typeConfig.Members.TryGetValue(name, out var memConfig))
                {
                    var o = _manager.DeserializeBsonValue(memConfig.TypeConfiguration, this, name, context);
                    _values[name] = o;
                }
                else
                {
                    _manager.DeserializeBsonIgnoredValue(context, name);
                }

                if (context.BsonReader.State == BsonReaderState.Type)
                {
                    context.BsonReader.ReadBsonType();
                }
            }
            context.BsonReader.ReadEndDocument();
        }
Esempio n. 2
0
        public void DeserializeBson(BsonDeserializingContext context)
        {
            context.BsonReader.ReadStartDocument();
            if (context.BsonReader.State == BsonReaderState.Type)
            {
                context.BsonReader.ReadBsonType();
            }
            while (context.BsonReader.State != BsonReaderState.EndOfDocument)
            {
                string name = context.BsonReader.ReadName(Utf8NameDecoder.Instance);

                var o = _manager.DeserializeBsonValue(_typeConfig.ValueType, this, name, context);
                _inner.Add(name, o);
                if (context.BsonReader.State == BsonReaderState.Type)
                {
                    context.BsonReader.ReadBsonType();
                }
            }
            context.BsonReader.ReadEndDocument();
        }