Skip to content

Commit 87fb02c

Browse files
committed
Added SetEventReference builder method
1 parent 644855a commit 87fb02c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Source/Shared/EventBuilder.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ public EventBuilder SetReferenceId(string referenceId) {
5353
return this;
5454
}
5555

56+
/// <summary>
57+
/// Allows you to reference a parent event by it's <seealso cref="Event.ReferenceId" /> property. This allows you to have parent and child relationships.
58+
/// </summary>
59+
/// <param name="name">Reference name</param>
60+
/// <param name="id">The reference id that points to a specific event</param>
61+
public EventBuilder SetEventReference(string name, string id) {
62+
if (String.IsNullOrEmpty(name))
63+
throw new ArgumentNullException(nameof(name));
64+
65+
if (!IsValidIdentifier(id))
66+
throw new ArgumentException("Id must contain between 8 and 100 alphanumeric or '-' characters.", nameof(id));
67+
68+
Target.SetProperty($"@ref:{name}", id);
69+
return this;
70+
}
71+
5672
private bool IsValidIdentifier(string value) {
5773
if (value == null)
5874
return true;

0 commit comments

Comments
 (0)