Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Float.TinCan.ActivityLibrary/TinCanStatementBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ public class TinCanStatementBuilder
/// </summary>
Verb verb;

/// <summary>
/// The timestamp for the statement to be built. Optional.
/// </summary>
DateTime timestamp;

/// <summary>
/// Gets the session ID for the statement to be build. Optional.
/// </summary>
/// <value>
/// The session ID for the statement to be build. Optional.
/// </value>
public Guid SessionId => context.registration.Value;

/// <summary>
/// Sets the name of the agent for the generated statement.
/// </summary>
Expand Down Expand Up @@ -280,6 +293,34 @@ public TinCanStatementBuilder SetVerb(Verb verb)
return this;
}

/// <summary>
/// Sets the session ID.
/// </summary>
/// <returns>This object, useful for chaining.</returns>
/// <param name="guid">The session ID GUID.</param>
public TinCanStatementBuilder SetSessionId(Guid guid)
{
if (context == null)
{
context = new Context();
}

context.registration = guid;

return this;
}

/// <summary>
/// Sets the timestamp.
/// </summary>
/// <param name="timestamp">The timestamp to use.</param>
/// <returns>This object, useful for chaining.</returns>
public TinCanStatementBuilder SetTimestamp(DateTime timestamp)
{
this.timestamp = timestamp;
return this;
}

/// <summary>
/// Build a statement using the parameters given so far.
/// </summary>
Expand All @@ -303,8 +344,14 @@ public Statement Build()
statement.target = activity;
}

if (timestamp != null)
{
statement.timestamp = timestamp;
}

statement.context = context;
statement.verb = verb;

statement.Stamp();

return statement;
Expand Down