2using System.Collections;
3using System.Collections.Generic;
4using System.Threading.Tasks;
13 internal class SingletonCursor<T> : ICursor<T>
15 private readonly T value;
18 private readonly Guid objectId;
19 private bool isCurrent =
false;
30 this.serializer = Serializer;
32 this.objectId = ObjectId;
47 throw new InvalidOperationException(
"Enumeration not started. Call MoveNext() first.");
59 return this.serializer;
61 throw new InvalidOperationException(
"Enumeration not started. Call MoveNext() first.");
69 public bool CurrentTypeCompatible =>
true;
76 public Guid CurrentObjectId
83 throw new InvalidOperationException(
"Enumeration not started. Call MoveNext() first.");
108 object IEnumerator.Current => this.Current;
117 public bool MoveNext() => this.MoveNextAsyncLocked().Result;
122 public void Reset() => this.isCurrent =
false;
130 public Task<bool> MoveNextAsyncLocked()
132 this.isCurrent = !this.isCurrent;
133 return Task.FromResult(this.isCurrent);
142 public Task<bool> MovePreviousAsyncLocked()
144 return this.MoveNextAsyncLocked();
147 public IEnumerator<T> GetEnumerator()
149 T[] A =
new T[] { this.value };
150 return (IEnumerator<T>)A.GetEnumerator();
160 public bool SameSortOrder(
string[] ConstantFields,
string[] SortOrder)
162 if (SortOrder is
null || SortOrder.Length != 1 ||
this.objectSerializer is
null)
165 string s = this.objectSerializer.ObjectIdMemberName;
166 return (SortOrder[0] == s || SortOrder[0] ==
"+" + s);
176 public bool ReverseSortOrder(
string[] ConstantFields,
string[] SortOrder)
178 if (SortOrder is
null || SortOrder.Length != 1 ||
this.objectSerializer is
null)
181 string s = this.objectSerializer.ObjectIdMemberName;
182 return (SortOrder[0] ==
"-" + s);
189 public Task ContinueAfterLocked(T LastItem)
191 this.isCurrent =
true;
192 return Task.CompletedTask;
199 public Task ContinueBeforeLocked(T LastItem)
201 this.isCurrent =
true;
202 return Task.CompletedTask;
Serializes a class, taking into account attributes defined in Attributes.
Interface for asynchronous enumerators.
Task< bool > MoveNextAsync()
Advances the enumerator to the next element of the collection.
Interface for object serializers.