Skip to content

Commit a5a222a

Browse files
author
Eric Busch
authored
Merge pull request #12 from gowithfloat/feature/session-identifiers
Added Session IDs
2 parents 1f095e9 + cd8f423 commit a5a222a

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Float.TinCan.ActivityLibrary/TinCanStatementBuilder.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ public class TinCanStatementBuilder
3333
/// </summary>
3434
Verb verb;
3535

36+
/// <summary>
37+
/// The timestamp for the statement to be built. Optional.
38+
/// </summary>
39+
DateTime timestamp;
40+
41+
/// <summary>
42+
/// Gets the session ID for the statement to be build. Optional.
43+
/// </summary>
44+
/// <value>
45+
/// The session ID for the statement to be build. Optional.
46+
/// </value>
47+
public Guid SessionId => context.registration.Value;
48+
3649
/// <summary>
3750
/// Sets the name of the agent for the generated statement.
3851
/// </summary>
@@ -280,6 +293,34 @@ public TinCanStatementBuilder SetVerb(Verb verb)
280293
return this;
281294
}
282295

296+
/// <summary>
297+
/// Sets the session ID.
298+
/// </summary>
299+
/// <returns>This object, useful for chaining.</returns>
300+
/// <param name="guid">The session ID GUID.</param>
301+
public TinCanStatementBuilder SetSessionId(Guid guid)
302+
{
303+
if (context == null)
304+
{
305+
context = new Context();
306+
}
307+
308+
context.registration = guid;
309+
310+
return this;
311+
}
312+
313+
/// <summary>
314+
/// Sets the timestamp.
315+
/// </summary>
316+
/// <param name="timestamp">The timestamp to use.</param>
317+
/// <returns>This object, useful for chaining.</returns>
318+
public TinCanStatementBuilder SetTimestamp(DateTime timestamp)
319+
{
320+
this.timestamp = timestamp;
321+
return this;
322+
}
323+
283324
/// <summary>
284325
/// Build a statement using the parameters given so far.
285326
/// </summary>
@@ -303,8 +344,14 @@ public Statement Build()
303344
statement.target = activity;
304345
}
305346

347+
if (timestamp != null)
348+
{
349+
statement.timestamp = timestamp;
350+
}
351+
306352
statement.context = context;
307353
statement.verb = verb;
354+
308355
statement.Stamp();
309356

310357
return statement;

0 commit comments

Comments
 (0)