using MongoDB.Bson;
using MongoDB.Bson.Serialization;

namespace MongoDriverBug
{
    public class IdentityGenerator : IIdGenerator
    {
        private static readonly IdentityGenerator instance = new IdentityGenerator();

        public static IdentityGenerator Instance
        {
            get
            {
                return instance;
            }
        }

        public object GenerateId()
        {
            return new Identity(ObjectId.GenerateNewId().ToByteArray());
        }

        public bool IsEmpty(object id)
        {
            return id == null || (Identity)id == Identity.Empty;
        }
    }
}
