예제 #1
0
        async Task <EventualConsistentEvent[]> Get(IEnumerable <EventData> data)
        {
            var tasks = data.Select(async eventData =>
            {
                var customConverter = CreateConverter(eventData.EventName);
                // TODO: don't call Type.GetType() and get event's Type from some cached context?
                // TODO: review code of this class and dependent classes (EventConverter etc)
                var @event = customConverter == null
                    ? (IEvent)_jsonConverter.Deserialize(eventData.Payload, Type.GetType(eventData.EventName))
                    : await customConverter.ConvertBack(eventData.Id, eventData.Payload);
                return(new EventualConsistentEvent(@event, eventData.HandlerName));
            });

            return(await TaskEx.OneAtATime(tasks));
        }