Initial Commit ...
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace xDataService.Mongo {
|
||||
public class XMongoAsyncCursor<T> : IAsyncCursor<T> {
|
||||
public IEnumerable<T> Current { get; }
|
||||
private IEnumerator<T> CurrentEnumerator { get; }
|
||||
|
||||
public XMongoAsyncCursor (IEnumerable<T> source) {
|
||||
this.Current = source;
|
||||
this.CurrentEnumerator = source.GetEnumerator ();
|
||||
}
|
||||
|
||||
public void Dispose () {
|
||||
CurrentEnumerator.Dispose ();
|
||||
}
|
||||
|
||||
public bool MoveNext (CancellationToken cancellationToken = default) {
|
||||
return CurrentEnumerator.MoveNext ();
|
||||
}
|
||||
|
||||
public Task<bool> MoveNextAsync (CancellationToken cancellationToken = default) {
|
||||
return Task.Run (
|
||||
() => CurrentEnumerator.MoveNext (),
|
||||
cancellationToken : cancellationToken
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user