1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System.Collections.Generic;
- namespace Wayne.Lib.Log
- {
- internal class EventLogStorage
- {
- #region Fields
- private Dictionary<LogConfigEventLogStorageType, ISubscriptionStorage> storageDict = new Dictionary<LogConfigEventLogStorageType, ISubscriptionStorage>();
- #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<EventLogEntry> entries = new List<EventLogEntry>();
- 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
- }
- }
|