void AddChangeWithoutCheckPoint(Change change)
        {
            changeStore.StoreChange(Id, change);
            ReplayChange(change);

            changeCount++;
        }
 protected override void StoreChange(string changeRootId, Change change, Func<Change, byte[]> serialiseAction)
 {
     lock (WriteLock)
     {
         base.StoreChange(changeRootId, change, serialiseAction);
     }
 }
        public Change Upcast(Change toUpcast)
        {
            AuthenticationSessionCachedChange change = GetChange(toUpcast);

            change.Session.ExpiresAfter = CalculateExpiresAfter(change);

            return toUpcast;
        }
        protected override void StoreChange(string changeRootId, Change change, Func<Change, byte[]> serialiseAction)
        {
            using (var session = new Session(instance))
            {
                int sequence = StoreChange(session, changeRootId, change, serialiseAction);

                if (!(change is CheckPointChange)) return;

                DeleteBelowSequence(session, changeRootId, sequence);
            }
        }
        int StoreChange(Session session, string changeRootId, Change change, Func<Change, byte[]> serialiseAction)
        {
            JET_DBID dbId = Esent.OpenDatabase(session, GetDatabaseFileName());

            using (var table = new Table(session, dbId, ChangeStoreTable.Name, OpenTableGrbit.None))
            {
                IDictionary<string, JET_COLUMNID> columns = Esent.GetColumns(session, table);

                using (var transaction = new Transaction(session))
                {
                    int autoIncrement = StoreChange(session, table, columns, changeRootId, change, serialiseAction);
                    transaction.Commit(CommitTransactionGrbit.None);

                    return autoIncrement;
                }
            }
        }
 byte[] SerialiseChange(Change toSerialise)
 {
     return serialiser.Serialise(toSerialise);
 }
 public void StoreRawChange(string changeRootId, Change change)
 {
     AddChange(changeRootId, change, SerialiseChange);
 }
 public Change Upcast(Change toUpcast)
 {
     toUpcast.As<SubscribeChange>().Schema.RepeatStrategy = ConstantTimeRepeatStrategy.EveryTenSeconds();
     return toUpcast;
 }
 void ReplayChange(Change change)
 {
     GetType()
         .GetMethod("ApplyChange", new[] {change.GetType()})
         .Invoke(this, new object[] {change});
 }
 public void StoreChange(string changeRootId, Change change)
 {
     change.Version = Change.LatestVersion;
     StoreChange(changeRootId, change, SerialiseChange);
 }
 void AddChange(string changeRootId, Change change, Func<Change, byte[]> serialiseAction)
 {
     AddChange(CreateChangeContainer(changeRootId, change, serialiseAction));
 }
 public Change Upcast(Change toUpcast)
 {
     toUpcast.As<MessageCheckpointChange>().CachedOn = new DateTime(2013, 11, 24);
     return toUpcast;
 }
        int StoreChange(
            Session session,
            Table table,
            IDictionary<string, JET_COLUMNID> columns,
            string changeRootId,
            Change change,
            Func<Change, byte[]> serialiseAction)
        {
            using (var update = new Update(session, table, JET_prep.Insert))
            {
                Esent.SetColumn(session, table, columns[ChangeStoreTable.ChangeRootIdColumn], changeRootId, Encoding.Unicode);
                Esent.SetColumn(session, table, columns[ChangeStoreTable.BodyColumn], serialiseAction(change));
                int autoIncrement = Esent.RetrieveAutoIncrementColumn(session, table, columns[ChangeStoreTable.SequenceColumn]);

                update.Save();

                return autoIncrement;
            }
        }
 protected override void StoreChange(string changeRootId, Change change, Func<Change, byte[]> serialiseAction)
 {
 }
 protected abstract void StoreChange(
     string changeRootId, 
     Change change, Func<Change, byte[]> serialiseAction);
 protected override void StoreChange(string changeRootId, Change change, Func<Change, byte[]> serialiseAction)
 {
     CheckpointIfPossible(changeRootId, change);
     AddChange(changeRootId, change, serialiseAction);
 }
 void CheckpointIfPossible(string changeRootId, Change change)
 {
     if (change is CheckPointChange) CheckPointChanges(changeRootId);
 }
 static AuthenticationSessionCachedChange GetChange(Change toUpcast)
 {
     return toUpcast.As<AuthenticationSessionCachedChange>();
 }
 ChangeContainer CreateChangeContainer(string changeRootId, Change change, Func<Change, byte[]> serialiseAction)
 {
     return new ChangeContainer(sequence++, changeRootId, serialiseAction(change));
 }
示例#20
0
 protected void AddChange(Change change)
 {
     if (ShouldCheckPoint()) UrgeCheckPoint();
     AddChangeWithoutCheckPoint(change);
 }