4using System.Threading.Tasks;
18 private static readonly SemaphoreSlim synchObj =
new SemaphoreSlim(1);
46 await synchObj.WaitAsync();
49 if (!eventHandlers.TryGetValue(
this.EventType, out Dictionary<string, CachedEventHandler> Handlers))
51 Handlers = await LoadEventHandlers(this.
EventType);
53 if (!Handlers.ContainsKey(
this.ObjectId))
58 else if (Handlers is
null)
60 Handlers =
new Dictionary<string, CachedEventHandler>()
81 await synchObj.WaitAsync();
84 if (eventHandlers.TryGetValue(
this.EventType, out Dictionary<string, CachedEventHandler> Handlers) &&
85 !(Handlers is
null) &&
86 Handlers.Remove(
this.ObjectId) &&
105 await synchObj.WaitAsync();
108 if (!eventHandlers.TryGetValue(
EventType, out Dictionary<string, CachedEventHandler> Handlers))
110 Dictionary<string, CachedEventHandler> List = await LoadEventHandlers(
EventType);
111 Handlers = List.Count == 0 ? null : List;
115 if (Handlers is
null)
118 int c = Handlers.Count;
120 Handlers.Values.CopyTo(Result, 0);
130 private static async Task<Dictionary<string, CachedEventHandler>> LoadEventHandlers(
string EventType)
133 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.