public void SetDocumentId(object document, object id)
{
var documentType = document.GetType();
if (documentType.IsValueType)
{
var message = string.Format("SetDocumentId cannot be used with value type {0}.", documentType.FullName);
throw new BsonSerializationException(message);
}
var idMemberMap = _classMap.IdMemberMap;
if (idMemberMap != null)
{
idMemberMap.Setter(document, id);
}
else
{
var message = string.Format("Class {0} has no Id member.", document.GetType().FullName);
throw new InvalidOperationException(message);
}
}