Example #1
0
        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)));
        }
Example #2
0
        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);
            }
        }
Example #3
0
 protected abstract void MapEvents(ProcessManagerEventMappingContext <TState> mappingContext);