Mercurial > pub > ImplabNet
view Implab.Test/MockPollComponent.cs @ 277:963b17c275be v3
Refactoring
Added <array> element to injection parameters
Working on registrations of factories
author | cin |
---|---|
date | Sat, 28 Apr 2018 18:48:09 +0300 |
parents | f1696cdc3d7a |
children |
line wrap: on
line source
using System; using System.Threading; using System.Threading.Tasks; using Implab.Components; namespace Implab.Test { public class MockPollComponent : PollingComponent { public Func<CancellationToken,Task> PollWorker { get; set;} public Func<CancellationToken, Task> StartWorker { get; set; } public Func<CancellationToken, Task> StopWorker { get; set; } public MockPollComponent(bool initialized) : base(initialized) { } protected async override Task Poll(CancellationToken ct) { if(PollWorker!= null) await PollWorker.Invoke(ct); } protected async override Task StopInternalAsync(CancellationToken ct) { await base.StopInternalAsync(ct); if (StopWorker != null) await StopWorker.Invoke(ct); } protected async override Task StartInternalAsync(CancellationToken ct) { await base.StartInternalAsync(ct); if (StartWorker != null) await StartWorker.Invoke(ct); } } }