public void DeserializeProperty(
     BsonReader bsonReader,
     object obj,
     BsonPropertyMap propertyMap
 )
 {
     var value = bsonReader.ReadDouble(propertyMap.ElementName);
     propertyMap.Setter(obj, value);
 }
コード例 #2
0
 public void DeserializeProperty(
     BsonReader bsonReader,
     object obj,
     BsonPropertyMap propertyMap
 )
 {
     var bsonType = bsonReader.PeekBsonType();
     BsonDouble value;
     if (bsonType == BsonType.Null) {
         bsonReader.ReadNull(propertyMap.ElementName);
         value = null;
     } else {
         value = BsonDouble.Create(bsonReader.ReadDouble(propertyMap.ElementName));
     }
     propertyMap.Setter(obj, value);
 }
コード例 #3
0
 public void DeserializeProperty(
     BsonReader bsonReader,
     object obj,
     BsonPropertyMap propertyMap
 )
 {
     BsonType bsonType = bsonReader.PeekBsonType();
     double doubleValue;
     if (bsonType == BsonType.Double) {
         doubleValue = bsonReader.ReadDouble(propertyMap.ElementName);
     } else if (bsonType == BsonType.Document) {
         bsonReader.ReadDocumentName(propertyMap.ElementName);
         bsonReader.ReadStartDocument();
         bsonReader.VerifyString("_t", typeof(float).FullName);
         doubleValue = bsonReader.ReadDouble("v");
         bsonReader.ReadEndDocument();
     } else {
         throw new FileFormatException("Element is not valid System.Single");
     }
     var value = doubleValue == double.MinValue ? float.MinValue : doubleValue == double.MaxValue ? float.MaxValue : (float) doubleValue;
     propertyMap.Setter(obj, value);
 }