Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
OffsetProcessor.cs
1using System.Threading.Tasks;
3
5{
9 public class OffsetProcessor : IProcessor<object>
10 {
11 private readonly IProcessor<object> processor;
12 private readonly bool isAsynchronous;
13 private int offset;
14
20 public OffsetProcessor(IProcessor<object> Processor, int Offset)
21 {
22 this.processor = Processor;
23 this.offset = Offset;
24 this.isAsynchronous = Processor.IsAsynchronous;
25 }
26
30 public bool IsAsynchronous => this.isAsynchronous;
31
37 public bool Process(object Object)
38 {
39 if (this.offset > 0)
40 {
41 this.offset--;
42 return true;
43 }
44 else
45 return this.processor.Process(Object);
46 }
47
53 public Task<bool> ProcessAsync(object Object)
54 {
55 if (this.offset > 0)
56 {
57 this.offset--;
58 return Task.FromResult(true);
59 }
60 else
61 return this.processor.ProcessAsync(Object);
62 }
63
68 public bool Flush() => this.processor.Flush();
69
74 public Task<bool> FlushAsync() => this.processor.FlushAsync();
75 }
76}
Processor that skips a given number of result records.
Task< bool > FlushAsync()
Called at the end of processing, to allow for flushing of buffers, etc.
OffsetProcessor(IProcessor< object > Processor, int Offset)
Processor that skips a given number of result records.
bool Process(object Object)
Processes an object synchronously.
Task< bool > ProcessAsync(object Object)
Processes an object asynchronously.
bool Flush()
Called at the end of processing, to allow for flushing of buffers, etc.
bool IsAsynchronous
If the processor operates asynchronously.
Interface for processors of objects.
Definition: IProcessor.cs:9
bool IsAsynchronous
If the processor operates asynchronously.
Definition: IProcessor.cs:13