Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ObjectIdCursor.cs
1using System;
2using System.Collections;
3using System.Threading.Tasks;
5
7{
12 internal class ObjectIdCursor<T> : ICursor<T>
13 {
14 private readonly ICursor<T> cursor;
15 private readonly string objectIdFieldName;
16
22 public ObjectIdCursor(ICursor<T> Cursor, string ObjectIdFieldName)
23 {
24 this.cursor = Cursor;
25 this.objectIdFieldName = ObjectIdFieldName;
26 }
27
33 public T Current => this.cursor.Current;
34
38 public IObjectSerializer CurrentSerializer => this.cursor.CurrentSerializer;
39
44 public bool CurrentTypeCompatible => this.cursor.CurrentTypeCompatible;
45
51 public Guid CurrentObjectId => this.cursor.CurrentObjectId;
52
56 public void Dispose()
57 {
58 }
59
67 Task<bool> IAsyncEnumerator.MoveNextAsync() => this.MoveNextAsyncLocked();
68
74 object IEnumerator.Current => this.Current;
75
83 public bool MoveNext() => this.MoveNextAsyncLocked().Result;
84
88 public void Reset() => this.cursor.Reset();
89
96 public Task<bool> MoveNextAsyncLocked()
97 {
98 return this.cursor.MoveNextAsyncLocked();
99 }
100
107 public Task<bool> MovePreviousAsyncLocked()
108 {
109 return this.cursor.MovePreviousAsyncLocked();
110 }
111
119 public bool SameSortOrder(string[] ConstantFields, string[] SortOrder)
120 {
121 return (SortOrder.Length == 1 && SortOrder[0] == this.objectIdFieldName);
122 }
123
131 public bool ReverseSortOrder(string[] ConstantFields, string[] SortOrder)
132 {
133 return (SortOrder.Length == 1 && SortOrder[0] == "-" + this.objectIdFieldName);
134 }
135
140 public Task ContinueAfterLocked(T LastItem)
141 {
142 return this.cursor.ContinueAfterLocked(LastItem);
143 }
144
149 public Task ContinueBeforeLocked(T LastItem)
150 {
151 return this.cursor.ContinueBeforeLocked(LastItem);
152 }
153 }
154}
Interface for asynchronous enumerators.
Task< bool > MoveNextAsync()
Advances the enumerator to the next element of the collection.