Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MaxCountEnumerator.cs
1using System;
2using System.Collections;
3using System.Threading.Tasks;
4
6{
11 {
12 private readonly IResultSetEnumerator e;
13 private readonly int count0;
14 private int count;
15
21 public MaxCountEnumerator(IResultSetEnumerator ItemEnumerator, int Count)
22 {
23 this.e = ItemEnumerator;
24 this.count = this.count0 = Count;
25 }
26
30 public object Current => this.e.Current;
31
35 public bool MoveNext()
36 {
37 return this.MoveNextAsync().Result;
38 }
39
46 public async Task<bool> MoveNextAsync()
47 {
48 if (this.count <= 0 || !await this.e.MoveNextAsync())
49 return false;
50
51 this.count--;
52
53 return true;
54 }
55
59 public void Reset()
60 {
61 this.count = this.count0;
62 this.e.Reset();
63 }
64 }
65}
Enumerator that limits the return set to a maximum number of records.
MaxCountEnumerator(IResultSetEnumerator ItemEnumerator, int Count)
Enumerator that limits the return set to a maximum number of records.
async Task< bool > MoveNextAsync()
Advances the enumerator to the next element of the collection.