コード例 #1
0
 public void DeserializeProperty(
     BsonReader bsonReader,
     object obj,
     BsonPropertyMap propertyMap
 )
 {
     var bsonType = bsonReader.PeekBsonType();
     BsonBinaryData value;
     if (bsonType == BsonType.Null) {
         bsonReader.ReadNull(propertyMap.ElementName);
         value = null;
     } else {
         byte[] bytes;
         BsonBinarySubType subType;
         bsonReader.ReadBinaryData(propertyMap.ElementName, out bytes, out subType);
         value = new BsonBinaryData(bytes, subType);
     }
     propertyMap.Setter(obj, value);
 }
 public void DeserializeProperty(
     BsonReader bsonReader,
     object obj,
     BsonPropertyMap propertyMap
 )
 {
     byte[] bytes;
     BsonBinarySubType subType;
     bsonReader.ReadBinaryData(propertyMap.ElementName, out bytes, out subType);
     if (bytes.Length != 16) {
         throw new FileFormatException("BinaryData length is not 16");
     }
     if (subType != BsonBinarySubType.Uuid) {
         throw new FileFormatException("BinaryData sub type is not Uuid");
     }
     var value = new Guid(bytes);
     propertyMap.Setter(obj, value);
 }