private void UpdateStreamDelete(StreamUpdate <T> update) { // Find the item in the cache, it must exist. if (!this.data.Remove(update.Message)) { throw new ArgumentException("The cache does not contain a message with the requested originating time"); } }
private void UpdateStreamAdd(StreamUpdate <T> update) { if (this.data.FirstOrDefault(m => m.OriginatingTime == update.Message.OriginatingTime) != default) { throw new ArgumentException("The cache already contains a message with the requested originating time"); } this.data.Add(update.Message); }
private void UpdateStreamReplace(StreamUpdate <T> update) { // Get the old message, it must exist. Message <T> oldMessage = this.data.FirstOrDefault(m => m.OriginatingTime == update.Message.OriginatingTime); if (oldMessage == default) { throw new ArgumentException("The cache does not contain a message with the requested originating time"); } // Remove the old message this.data.Remove(oldMessage); // Insert the new message this.UpdateStreamAdd(update); }
/// <summary> /// Initializes a new instance of the <see cref="StreamUpdateWithView{T}"/> class. /// </summary> /// <param name="streamUpdate">An existing stream update to convert to a stream update with view.</param> /// <param name="view">The view of the data cache spanning the duration of the update.</param> public StreamUpdateWithView(StreamUpdate <T> streamUpdate, ObservableKeyedCache <DateTime, Message <T> > .ObservableKeyedView view) : base(streamUpdate.UpdateType, streamUpdate.Message) { this.View = view; }