public ITrackingToken AdvancedTo(ITrackingToken newToken) { if ((newToken.Covers(IWrappedToken.UnwrapUpperBound(_tokenAtReset)) && !_tokenAtReset.Covers(IWrappedToken.UnwrapLowerBound(newToken)))) { // we're done replaying // if the token at reset was a wrapped token itself, we'll need to use that one to maintain progress. return(_tokenAtReset is IWrappedToken wrappedToken?wrappedToken.AdvancedTo(newToken) : newToken); } if (_tokenAtReset.Covers(IWrappedToken.UnwrapLowerBound(newToken))) { // we're still well behind return(new ReplayToken(_tokenAtReset, newToken, true)); } // we're getting an event that we didn't have before, but we haven't finished replaying either if (_tokenAtReset is IWrappedToken token) { return(new ReplayToken(token.UpperBound(newToken), token.AdvancedTo(newToken), false)); } return(new ReplayToken(_tokenAtReset.UpperBound(newToken), newToken, false)); }
public static ITrackingToken CreateReplayToken(ITrackingToken tokenAtReset, ITrackingToken startPosition) { if (tokenAtReset == null) { return(null); } if (tokenAtReset is ReplayToken) { return(CreateReplayToken(((ReplayToken)tokenAtReset).TokenAtReset, startPosition)); } if (startPosition != null && startPosition.Covers(tokenAtReset)) { return(startPosition); } return(new ReplayToken(tokenAtReset, startPosition)); }
public ITrackingToken AdvancedTo(ITrackingToken newToken) { if (TokenAtReset == null || (newToken.Covers(this.TokenAtReset) && !TokenAtReset.Covers(newToken))) { // we're done replaying return(newToken); } else if (TokenAtReset.Covers(newToken)) { // we're still well behind return(new ReplayToken(TokenAtReset, newToken)); } else { // we're getting an event that we didn't have before, but we haven't finished replaying either return(new ReplayToken(TokenAtReset.UpperBound(newToken), newToken)); } }