forked from kurrent-io/KurrentDB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResolvedEvent.cs
More file actions
65 lines (56 loc) · 2.39 KB
/
ResolvedEvent.cs
File metadata and controls
65 lines (56 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using EventStore.ClientAPI.Messages;
namespace EventStore.ClientAPI
{
/// <summary>
/// A structure representing a single event or an resolved link event.
/// </summary>
public struct ResolvedEvent
{
/// <summary>
/// The event, or the resolved link event if this <see cref="ResolvedEvent"/> is
/// a link event.
/// </summary>
public readonly RecordedEvent Event;
/// <summary>
/// The link event if this <see cref="ResolvedEvent"/> is a link event.
/// </summary>
public readonly RecordedEvent Link;
/// <summary>
/// Returns the event that was read or which triggered the subscription.
///
/// If this <see cref="ResolvedEvent"/> represents a link event, the Link
/// will be the <see cref="OriginalEvent"/>, otherwise it will be the
/// Event.
/// </summary>
public RecordedEvent OriginalEvent { get { return Link ?? Event; } }
/// <summary>
/// Indicates whether this <see cref="ResolvedEvent"/> is a resolved link
/// event.
/// </summary>
public bool IsResolved { get { return Link != null && Event != null; } }
/// <summary>
/// The logical position of the <see cref="OriginalEvent"/>.
/// </summary>
public readonly Position? OriginalPosition;
/// <summary>
/// The stream name of the <see cref="OriginalEvent" />.
/// </summary>
public string OriginalStreamId { get { return OriginalEvent.EventStreamId; } }
/// <summary>
/// The event number in the stream of the <see cref="OriginalEvent"/>.
/// </summary>
public int OriginalEventNumber { get { return OriginalEvent.EventNumber; } }
internal ResolvedEvent(ClientMessage.ResolvedEvent evnt)
{
Event = evnt.Event == null ? null : new RecordedEvent(evnt.Event);
Link = evnt.Link == null ? null : new RecordedEvent(evnt.Link);
OriginalPosition = new Position(evnt.CommitPosition, evnt.PreparePosition);
}
internal ResolvedEvent(ClientMessage.ResolvedIndexedEvent evnt)
{
Event = evnt.Event == null ? null : new RecordedEvent(evnt.Event);
Link = evnt.Link == null ? null : new RecordedEvent(evnt.Link);
OriginalPosition = null;
}
}
}