This repository has been archived by the owner on Dec 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 228
/
Cursor.cs
196 lines (178 loc) · 5.98 KB
/
Cursor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
using System;
using System.Collections.Generic;
namespace MongoDB
{
/// <summary>
/// <see cref="ICursor"/>
/// </summary>
public class Cursor : ICursor
{
private readonly ICursor<Document> _cursor;
/// <summary>
/// Initializes a new instance of the <see cref="Cursor"/> class.
/// </summary>
/// <param name="cursor">The cursor.</param>
internal Cursor(ICursor<Document> cursor)
{
_cursor = cursor;
}
/// <summary>
/// Gets the id.
/// </summary>
/// <value>The id.</value>
public long Id
{
get { return _cursor.Id; }
}
/// <summary>
/// Specs the specified spec.
/// </summary>
/// <param name="spec">The spec.</param>
/// <returns></returns>
public ICursor Spec(Document spec){
_cursor.Spec(spec);
return this;
}
/// <summary>
/// Limits the specified limit.
/// </summary>
/// <param name="limit">The limit.</param>
/// <returns></returns>
public ICursor Limit(int limit){
_cursor.Limit(limit);
return this;
}
/// <summary>
/// Skips the specified skip.
/// </summary>
/// <param name="skip">The skip.</param>
/// <returns></returns>
public ICursor Skip(int skip){
_cursor.Skip(skip);
return this;
}
/// <summary>
/// Fieldses the specified fields.
/// </summary>
/// <param name="fields">The fields.</param>
/// <returns></returns>
public ICursor Fields(Document fields){
return this;
}
/// <summary>
/// Optionses the specified options.
/// </summary>
/// <param name="options">The options.</param>
/// <returns></returns>
public ICursor Options(QueryOptions options){
_cursor.Options(options);
return this;
}
/// <summary>
/// Sorts the specified field.
/// </summary>
/// <param name="field">The field.</param>
/// <returns></returns>
public ICursor Sort(string field){
_cursor.Sort(field);
return this;
}
/// <summary>
/// Sorts the specified field.
/// </summary>
/// <param name="field">The field.</param>
/// <param name="order">The order.</param>
/// <returns></returns>
public ICursor Sort(string field, IndexOrder order){
_cursor.Sort(field, order);
return this;
}
/// <summary>
/// Sorts the specified fields.
/// </summary>
/// <param name="fields">The fields.</param>
/// <returns></returns>
public ICursor Sort(Document fields){
_cursor.Sort(fields);
return this;
}
/// <summary>
/// Hints the specified index.
/// </summary>
/// <param name="index">The index.</param>
/// <returns></returns>
public ICursor Hint(Document index){
_cursor.Hint(index);
return this;
}
/// <summary>
/// Keeps the cursor open.
/// </summary>
/// <param name="value">if set to <c>true</c> [value].</param>
/// <returns></returns>
/// <remarks>
/// By default cursors are closed automaticly after documents
/// are Enumerated.
/// </remarks>
public ICursor KeepCursor(bool value)
{
_cursor.KeepCursor(value);
return this;
}
/// <summary>
/// Snapshots this instance.
/// </summary>
/// <returns></returns>
public ICursor Snapshot(){
_cursor.Snapshot();
return this;
}
/// <summary>
/// Explains this instance.
/// </summary>
/// <returns></returns>
public Document Explain(){
return _cursor.Explain();
}
/// <summary>
/// Gets a value indicating whether this instance is modifiable.
/// </summary>
/// <value>
/// <c>true</c> if this instance is modifiable; otherwise, <c>false</c>.
/// </value>
public bool IsModifiable {
get { return _cursor.IsModifiable; }
}
/// <summary>
/// Gets the documents.
/// </summary>
/// <value>The documents.</value>
public IEnumerable<Document> Documents {
get {return _cursor.Documents;}
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose(){
_cursor.Dispose();
}
}
}
// /// <summary>
// /// Initializes a new instance of the <see cref = "Cursor<T>" /> class.
// /// </summary>
// /// <param name = "connection">The conn.</param>
// /// <param name = "fullCollectionName">Full name of the collection.</param>
// public Cursor(Connection connection, string fullCollectionName):base(connection, fullCollectionName){
//
// }
//
// /// <summary>
// /// Initializes a new instance of the <see cref = "Cursor<T>" /> class.
// /// </summary>
// /// <param name = "connection">The conn.</param>
// /// <param name = "fullCollectionName">Full name of the collection.</param>
// [Obsolete("Use Cursor(Connection, fullCollectionName) and then call the Spec, Limit, Skip and Fields methods")]
// public Cursor(Connection connection, string fullCollectionName, Document spec, int limit, int skip, Document fields)
// :base(connection, fullCollectionName, spec, limit, skip, fields){
// }