/// <summary> /// /// </summary> /// <param name="events"></param> /// <param name="jsonSerializer"></param> /// <param name="partitionKey"></param> /// <returns></returns> public static Commit From(UncommittedEventStream events, ISerializer jsonSerializer, string partitionKey) { var eventDocs = events.Events.Select(e => new Event { Id = e.Id, CorrelationId = e.Metadata.CorrelationId, EventArtifact = e.Metadata.Artifact.Id, EventSourceId = e.Metadata.EventSourceId, Generation = e.Metadata.Artifact.Generation, EventSourceArtifact = events.Source.Artifact, Commit = e.Metadata.VersionedEventSource.Version.Commit, Sequence = e.Metadata.VersionedEventSource.Version.Sequence, Occurred = e.Metadata.Occurred.ToUnixTimeMilliseconds(), OriginalContext = OriginalContext.From(e.Metadata.OriginalContext), EventData = PropertyBagSerializer.Serialize(e.Event, jsonSerializer) }); var commit = new Commit { Id = "0", CorrelationId = events.CorrelationId, CommitId = events.Id, Timestamp = events.Timestamp.ToUnixTimeMilliseconds(), EventSourceId = events.Source.EventSource, EventSourceArtifact = events.Source.Artifact, CommitNumber = events.Source.Version.Commit, Sequence = events.Source.Version.Sequence, Events = eventDocs.ToArray(), PartitionKey = partitionKey }; return(commit); }
PropertyBag ToPropertyBag(ISerializer serializer) { return(PropertyBagSerializer.From(EventData, serializer)); }