Ejemplo n.º 1
0
    /// <summary>
    /// Converts the <see cref="CommittedEvent" /> to <see cref="Contracts.EventHorizonCommittedEvent" />.
    /// </summary>
    /// <param name="event">The <see cref="CommittedEvent" />.</param>
    /// <returns>The <see cref="Contracts.EventHorizonCommittedEvent" />.</returns>
    public static Contracts.EventHorizonCommittedEvent ToEventHorizonCommittedEvent(this CommittedEvent @event)
    {
        var committedEvent = new Contracts.EventHorizonCommittedEvent
        {
            EventLogSequenceNumber = @event.EventLogSequenceNumber,
            Occurred         = Timestamp.FromDateTimeOffset(@event.Occurred),
            EventSourceId    = @event.EventSource.Value,
            ExecutionContext = @event.ExecutionContext.ToProtobuf(),
            EventType        = new Dolittle.Artifacts.Contracts.Artifact
            {
                Id         = @event.Type.Id.ToProtobuf(),
                Generation = @event.Type.Generation
            },
            Content = @event.Content,
            Public  = @event.Public,
        };

        if (Guid.TryParse(@event.EventSource, out var eventSourceGuid))
        {
            committedEvent.EventSourceIdLegacy = eventSourceGuid.ToProtobuf();
        }
        committedEvent.ExecutionContext.Claims.Clear();
        committedEvent.ExecutionContext.Claims.AddRange(Claims.Empty.ToProtobuf());
        return(committedEvent);
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Convert to from <see cref="Contracts.EventHorizonCommittedEvent"/> to <see cref="CommittedEvent"/>.
 /// </summary>
 /// <param name="event"><see cref="Contracts.EventHorizonCommittedEvent"/> to convert from.</param>
 /// <returns>Converted <see cref="CommittedEvent"/>.</returns>
 public static CommittedEvent ToCommittedEvent(this Contracts.EventHorizonCommittedEvent @event) =>