private void OnEntriesExpired(object sender, ExpiringSet <TKey, TValue> .ExpiredArgs e) { if (EntryExpired == null) { return; } foreach (var entry in e.Entries) { EntryExpired(this, new ExpirationArgs <TKey, TValue>(Entry.FromExpiringSetEntry(entry))); } }
//--- Class Methods --- internal static Entry FromExpiringSetEntry(ExpiringSet <TKey, TValue> .Entry entry) { return(new Entry(entry.Key, entry.Value, entry.When, entry.TTL)); }
/// <summary> /// Create a new hashset /// </summary> /// <param name="taskTimerFactory">The timer factory to create the set's timer from</param> /// <param name="autoRefresh"><see langword="True"/> if accessing an entry should extend the expiration time by the time-to-live</param> public ExpiringDictionary(TaskTimerFactory taskTimerFactory, bool autoRefresh) { _set = new ExpiringSet <TKey, TValue>(taskTimerFactory, autoRefresh); _set.CollectionChanged += OnCollectionChanged; _set.EntriesExpired += OnEntriesExpired; }
/// <summary> /// Create a new hashset /// </summary> /// <param name="taskTimerFactory">The timer factory to create the set's timer from</param> /// <param name="autoRefresh"><see langword="True"/> if accessing an entry should extend the expiration time by the time-to-live</param> public ExpiringHashSet(TaskTimerFactory taskTimerFactory, bool autoRefresh) { _set = new ExpiringSet <T, T>(taskTimerFactory, autoRefresh); _set.CollectionChanged += OnCollectionChanged; _set.EntriesExpired += OnEntriesExpired; }