public IReadOnlyDictionary <Type, string> GetEventMappings() { var eventMappings = new Dictionary <Type, Tuple <Func <object, TState, IDictionary <string, object>, Task>, Func <object, string>, string> >(); var mappingContext = new ProcessManagerEventMappingContext <TState>(eventMappings); MapEvents(mappingContext); return(new ReadOnlyDictionary <Type, string>(eventMappings.ToDictionary(x => x.Key, x => x.Value.Item3))); }
public async Task Apply(object evnt, IDictionary <string, object> metaData) { var eventMappings = new Dictionary <Type, Tuple <Func <object, TState, IDictionary <string, object>, Task>, Func <object, string>, string> >(); var mappingContext = new ProcessManagerEventMappingContext <TState>(eventMappings); MapEvents(mappingContext); foreach (var type in GetTypesFrom(evnt)) { if (!eventMappings.ContainsKey(type)) { continue; } var handlerMapping = eventMappings[type]; var id = handlerMapping.Item2(evnt); await handlerMapping.Item1(evnt, await _repository.Load <TState>(GetStreamName(id), id).ConfigureAwait(false), metaData).ConfigureAwait(false); } }
protected abstract void MapEvents(ProcessManagerEventMappingContext <TState> mappingContext);