private Fact MapToFact(StreamMessage streamMessage)
        {
            var eventType = _eventMapping.GetEventType(streamMessage.Type);
            var eventData = streamMessage.GetJsonData().GetAwaiter().GetResult();
            var @event    = _eventDeserializer.DeserializeObject(eventData, eventType);

            return(new Fact(streamMessage.StreamId, @event));
        }
Ejemplo n.º 2
0
        public object Create(StreamMessage message)
        {
            var @event = Deserialize(message);

            var deserializedMetadata = (Dictionary <string, object>)_eventDeserializer.DeserializeObject(message.JsonMetadata, typeof(Dictionary <string, object>));
            var metadata             = deserializedMetadata != null
                ? new Dictionary <string, object>(deserializedMetadata, StringComparer.OrdinalIgnoreCase)
                : new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);

            metadata[Envelope.PositionMetadataKey]   = message.Position;
            metadata[Envelope.EventNameMetadataKey]  = message.Type;
            metadata[Envelope.CreatedUtcMetadataKey] = message.CreatedUtc;

            var envelope =
                new Envelope(
                    @event,
                    metadata)
                .ToGenericEnvelope();

            return(envelope);
        }