Repository navigation
Expand file tree
/
Copy pathConditionalWriteResult.cs
More file actions
52 lines (47 loc) · 1.71 KB
/
Copy pathConditionalWriteResult.cs
File metadata and controls
52 lines (47 loc) · 1.71 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
using System;
namespace EventStore.ClientAPI
{
/// <summary>
/// Result type returned after conditionally writing to a stream.
/// </summary>
public struct ConditionalWriteResult
{
/// <summary>
/// Returns if the write was successful.
/// </summary>
public readonly ConditionalWriteStatus Status;
/// <summary>
/// The next expected version for the stream.
/// </summary>
public readonly int? NextExpectedVersion;
/// <summary>
/// The <see cref="LogPosition"/> of the write.
/// </summary>
public readonly Position? LogPosition;
/// <summary>
/// Constructs a new <see cref="WriteResult"/>.
/// </summary>
/// <param name="nextExpectedVersion">The next expected version for the stream.</param>
/// <param name="logPosition">The position of the write in the log</param>
public ConditionalWriteResult(int nextExpectedVersion, Position logPosition)
{
LogPosition = logPosition;
NextExpectedVersion = nextExpectedVersion;
Status = ConditionalWriteStatus.Succeeded;
}
/// <summary>
/// Constructs a new <see cref="WriteResult"/>.
/// </summary>
/// <param name="status">The status of the write operation.</param>
public ConditionalWriteResult(ConditionalWriteStatus status)
{
if (status == ConditionalWriteStatus.Succeeded)
{
throw new Exception("For successful write pass next expected version and log position.");
}
LogPosition = null;
NextExpectedVersion = null;
Status = status;
}
}
}