2using System.Collections.Generic;
5using System.Threading.Tasks;
20 private static readonly SemaphoreSlim synchObj =
new SemaphoreSlim(1);
48 await synchObj.WaitAsync();
51 if (!eventHandlers.TryGetValue(
this.EventType, out Dictionary<string, CachedEventHandler> Handlers))
53 Handlers = await LoadEventHandlers(this.
EventType);
55 if (!Handlers.ContainsKey(
this.ObjectId))
60 else if (Handlers is
null)
62 Handlers =
new Dictionary<string, CachedEventHandler>()
83 await synchObj.WaitAsync();
86 if (eventHandlers.TryGetValue(
this.EventType, out Dictionary<string, CachedEventHandler> Handlers) &&
87 !(Handlers is
null) &&
88 Handlers.Remove(
this.ObjectId) &&
107 await synchObj.WaitAsync();
110 if (!eventHandlers.TryGetValue(
EventType, out Dictionary<string, CachedEventHandler> Handlers))
112 Dictionary<string, CachedEventHandler> List = await LoadEventHandlers(
EventType);
113 Handlers = List.Count == 0 ? null : List;
117 if (Handlers is
null)
120 int c = Handlers.Count;
122 Handlers.Values.CopyTo(Result, 0);
132 private static async Task<Dictionary<string, CachedEventHandler>> LoadEventHandlers(
string EventType)
135 Dictionary<string, CachedEventHandler> Result =
new Dictionary<string, CachedEventHandler>();
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static Task< IEnumerable< object > > Find(string Collection, params string[] SortOrder)
Finds objects in a given collection.
This filter selects objects that have a named field equal to a given value.
Implements an in-memory cache.
Abstract base class for cached event handlers.
CachedEventHandler(EvaluationArguments Arguments, int EventIndex)
Event handler for entry events.
async Task AddToCache()
Removes the event handler from the cache.
static async Task< CachedEventHandler[]> GetEventHandlers(string EventType)
Gets registered event handlers of a given event type.
CachedEventHandler()
Abstract base class for cached event handlers.
async Task RemoveFromCache()
Removes the event handler from the cache.
Abstract base class for persisted state-machine event handlers.
string ObjectId
Object ID of event handler.
string EventType
Type of event.
int EventIndex
Zero-based index of event handler in state.
Contains information required for evaluating script in a state-machine.