-
Notifications
You must be signed in to change notification settings - Fork 14
/
FlowIdGenerator.cs
35 lines (31 loc) · 1014 Bytes
/
FlowIdGenerator.cs
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
// ReSharper disable ClassNeverInstantiated.Global
namespace TeamCity.VSTest.TestLogger
{
using System;
using JetBrains.TeamCity.ServiceMessages.Write.Special;
internal class FlowIdGenerator : IFlowIdGenerator
{
private readonly IIdGenerator _idGenerator;
private readonly IOptions _options;
private bool _isFirst = true;
public FlowIdGenerator(IIdGenerator idGenerator, IOptions options)
{
_idGenerator = idGenerator ?? throw new ArgumentNullException(nameof(idGenerator));
_options = options;
}
public string NewFlowId()
{
// ReSharper disable once InvertIf
if (_isFirst)
{
_isFirst = false;
var flowId = _options.RootFlowId;
if (!string.IsNullOrEmpty(flowId))
{
return flowId;
}
}
return _idGenerator.NewId();
}
}
}