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;
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 void Dispose()
36 {
37 this.e.Dispose();
38 }
39
43 public bool MoveNext()
44 {
45 return this.MoveNextAsync().Result;
46 }
47
54 public async Task<bool> MoveNextAsync()
55 {
56 if (this.count <= 0 || !await this.e.MoveNextAsync())
57 return false;
58
59 this.count--;
60
61 return true;
62 }
63
67 public void Reset()
68 {
69 this.count = this.count0;
70 this.e.Reset();
71 }
72 }
73}
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.