using System.Collections.Generic; namespace Wayne.Lib.Log { internal class EventLogStorage { #region Fields private Dictionary storageDict = new Dictionary(); #endregion #region Construction public EventLogStorage() { storageDict[LogConfigEventLogStorageType.Volatile] = new VolatileStorage(); storageDict[LogConfigEventLogStorageType.NoStorage] = new NoStorage(); storageDict[LogConfigEventLogStorageType.RestartSafe] = new FileSystemStorage(); } #endregion #region Methods internal void Add(string subscriberId, EventLogEntry logEntry, LogConfigEventLogStorageType storageType) { storageDict[storageType].Add(subscriberId, logEntry); } internal EventLogEntry[] GetPendingEvents(string eventSubscriberId) { List entries = new List(); foreach (ISubscriptionStorage storage in storageDict.Values) entries.AddRange(storage.GetStoredEvents(eventSubscriberId)); return entries.ToArray(); } internal void Remove(IEventSubscriber eventSubscriber, EventLogEntry eventLogEntry) { foreach (ISubscriptionStorage storage in storageDict.Values) storage.Remove(eventSubscriber.SubscriberId, eventLogEntry); } #endregion } }