public override void CreateUninitializedItem(HttpContext context, string id, int timeout)
        {
            var newSession = new MongoSession {
                Id = id,
                CreatedDate = DateTime.Now,
                ExpiresDate = DateTime.Now.AddMinutes(timeout),
                LockId = ObjectId.Empty,
                LockedDate = DateTime.Now,
                IsLocked = false,
                Timeout = timeout,
                Properties = null,
                Actions = SessionStateActions.InitializeItem
            };

            try {
                var sessions = GetSessionCollection();
                sessions.Insert(newSession);
            } catch (MongoSafeModeException e) {
                var message = ProviderResources.CouldNotCreateSession;
                throw TraceException("CreateUninitializedItem", new ProviderException(message, e));
            }
        }
        public override void SetAndReleaseItemExclusive(HttpContext context, string id, SessionStateStoreData storeData, object lockId, bool newStoreData)
        {
            if (!newStoreData && !(lockId is ObjectId)) {
                var message = ProviderResources.LockIdMustBeAnObjectId;
                throw TraceException("SetAndReleaseItemExclusive", new ArgumentException(message, "lockId"));
            }
            if (!StoreDataKeysAreValid(storeData)) {
                var message = ProviderResources.IllegalSessionKeyName;
                throw TraceException("SetAndReleaseItemExclusive", new ProviderException(message));
            }

            var sessions = GetSessionCollection();
            if (newStoreData) {
                // Ensure expired session is removed first, if it exists.
                try {
                    sessions.Remove(Query.EQ("_id", id));
                    var session = new MongoSession {
                        Id = id,
                        CreatedDate = DateTime.Now,
                        ExpiresDate = DateTime.Now.AddMinutes(storeData.Timeout),
                        LockId = ObjectId.Empty,
                        LockedDate = DateTime.Now,
                        IsLocked = false,
                        Timeout = storeData.Timeout,
                        Properties = ConvertStoreDataToBsonDocument(storeData),
                        Actions = SessionStateActions.None
                    };
                    sessions.Insert(session);
                } catch (MongoSafeModeException e) {
                    var message = ProviderResources.CouldNotCreateSession;
                    throw TraceException("SetAndReleaseItemExclusive", new ProviderException(message, e));
                }
            } else {
                try {
                    var query = Query.And(
                        Query.EQ("_id", id),
                        Query.EQ("LockId", (ObjectId) lockId));
                    var expiresDate = SerializationHelper.SerializeDateTime(DateTime.Now.AddMinutes(storeData.Timeout));
                    var update = Update
                        .Set("ExpiresDate", expiresDate)
                        .Set("IsLocked", false)
                        .Set("Properties", ConvertStoreDataToBsonDocument(storeData));
                    sessions.Update(query, update);
                } catch (MongoSafeModeException e) {
                    var message = ProviderResources.CouldNotUpdateSession;
                    throw TraceException("SetAndReleaseItemExclusive", new ProviderException(message, e));
                }
            }
        }