コード例 #1
0
        /// <summary>
        /// Constructs an <see cref="IComponentConditionEvaluator" />.
        /// When called multiple times builds a reference count to monitor the condition
        /// across multiple streams.
        /// </summary>
        /// <param name="timespanFactory">The <see cref="TimeSpan"/> factory.</param>
        /// <param name="ct">The cancellation token.</param>
        /// <returns></returns>
        public async Task <IComponentConditionEvaluator> BuildAsync(IConditionInstanceTimeSpanFactory timespanFactory, CancellationToken ct = default)
        {
            if (!_monitoring)
            {
                await StartMonitorAsync(timespanFactory, ct).ConfigureAwait(false);

                _monitoring = true;
            }

            return(await _manager.CreateEvaluatorAsync(ct));
        }
コード例 #2
0
 public void SetUp()
 {
     _timeSpanFactory = A.Dummy <IConditionInstanceTimeSpanFactory>();
     _sut             = A.Fake <ComponentMonitorSpecification>();
 }
コード例 #3
0
 /// <summary>
 /// Called when creating the first evaluator to initialize monitoring for condition instances within the component.
 /// </summary>
 /// <param name="timeSpanFactory">The <see cref="TimeSpan"/> factory.</param>
 /// <param name="ct">The cancelation token.</param>
 /// <returns></returns>
 protected abstract Task StartMonitorAsync(IConditionInstanceTimeSpanFactory timeSpanFactory, CancellationToken ct);
コード例 #4
0
 protected override Task StartMonitorAsync(IConditionInstanceTimeSpanFactory timeSpanFactory, CancellationToken ct)
 {
     _timeSpanFactory = timeSpanFactory;
     _eventMonitorSink.AddEvaluator(typeof(TEvent), this);
     return(Task.CompletedTask);
 }