Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PredicateProcessor.cs
1using System;
2using System.Threading.Tasks;
3
5{
10 public class PredicateProcessor<T> : IProcessor<T>
11 {
12 private readonly Predicate<T> callback;
13
19 public PredicateProcessor(Predicate<T> Callback)
20 {
21 this.callback = Callback;
22 }
23
27 public bool IsAsynchronous => false;
28
34 public bool Process(T Object) => this.callback(Object);
35
41 public Task<bool> ProcessAsync(T Object) => Task.FromResult(this.callback(Object));
42
47 public bool Flush()
48 {
49 return true;
50 }
51
56 public Task<bool> FlushAsync()
57 {
58 return Task.FromResult(true);
59 }
60 }
61}
Processor that uses a predicate callback to process objects.
Task< bool > ProcessAsync(T Object)
Processes an object asynchronously.
bool Process(T Object)
Processes an object synchronously.
PredicateProcessor(Predicate< T > Callback)
Processor that uses a predicate callback to process objects.
Task< bool > FlushAsync()
Called at the end of processing, to allow for flushing of buffers, etc.
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