public static Type AsType(this BsonValue bsonValue)
{
string typeName = bsonValue.AsString;
Type type = Type.GetType(typeName);
if (type == null)
{
throw new SerializationException($"Cannot load type: {typeName}. Make sure that assembly containing this type is referenced by your project.");
}
return type;
}
}