/// <summary> /// Saves a continuation point used for historical reads. /// </summary> /// <param name="id">The identifier for the continuation point.</param> /// <param name="continuationPoint">The continuation point.</param> /// <remarks> /// If the continuationPoint implements IDisposable it will be disposed when /// the Session is closed or discarded. /// </remarks> public void SaveHistoryContinuationPoint(Guid id, object continuationPoint) { if (continuationPoint == null) { throw new ArgumentNullException("continuationPoint"); } lock (m_lock) { if (m_historyContinuationPoints == null) { m_historyContinuationPoints = new List <HistoryContinuationPoint>(); } // remove existing continuation point if space needed. while (m_historyContinuationPoints.Count >= m_maxHistoryContinuationPoints) { HistoryContinuationPoint oldCP = m_historyContinuationPoints[0]; m_historyContinuationPoints.RemoveAt(0); Utils.SilentDispose(oldCP.Value); } // create the cp. HistoryContinuationPoint cp = new HistoryContinuationPoint(); cp.Id = id; cp.Value = continuationPoint; cp.Timestamp = DateTime.UtcNow; m_historyContinuationPoints.Add(cp); } }
/// <summary> /// Restores a previously saves history continuation point. /// </summary> /// <param name="continuationPoint">The identifier for the continuation point.</param> /// <returns>The save continuation point. null if not found.</returns> public object RestoreHistoryContinuationPoint(byte[] continuationPoint) { lock (m_lock) { if (m_historyContinuationPoints == null) { return(null); } if (continuationPoint == null || continuationPoint.Length != 16) { return(null); } Guid id = new Guid(continuationPoint); for (int ii = 0; ii < m_historyContinuationPoints.Count; ii++) { HistoryContinuationPoint cp = m_historyContinuationPoints[ii]; if (cp.Id == id) { m_historyContinuationPoints.RemoveAt(ii); return(cp.Value); } } return(null); } }
/// <summary> /// Saves a continuation point used for historical reads. /// </summary> /// <param name="id">The identifier for the continuation point.</param> /// <param name="continuationPoint">The continuation point.</param> /// <remarks> /// If the continuationPoint implements IDisposable it will be disposed when /// the Session is closed or discarded. /// </remarks> public void SaveHistoryContinuationPoint(Guid id, object continuationPoint) { if (continuationPoint == null) throw new ArgumentNullException("continuationPoint"); lock (m_lock) { if (m_historyContinuationPoints == null) { m_historyContinuationPoints = new List<HistoryContinuationPoint>(); } // remove existing continuation point if space needed. while (m_historyContinuationPoints.Count >= m_maxHistoryContinuationPoints) { HistoryContinuationPoint oldCP = m_historyContinuationPoints[0]; m_historyContinuationPoints.RemoveAt(0); Utils.SilentDispose(oldCP.Value); } // create the cp. HistoryContinuationPoint cp = new HistoryContinuationPoint(); cp.Id = id; cp.Value = continuationPoint; cp.Timestamp = DateTime.UtcNow; m_historyContinuationPoints.Add(cp); } }