23
23
24
24
namespace MongoDB . Driver
25
25
{
26
+ /// <summary>
27
+ /// Represents collection system flags.
28
+ /// </summary>
29
+ [ Flags ]
30
+ public enum CollectionSystemFlags
31
+ {
32
+ /// <summary>
33
+ /// No flags.
34
+ /// </summary>
35
+ None = 0 ,
36
+ /// <summary>
37
+ /// The collection has an _id index.
38
+ /// </summary>
39
+ HaveIdIndex = 1
40
+ }
41
+
42
+ /// <summary>
43
+ /// Represents collection user flags.
44
+ /// </summary>
45
+ [ Flags ]
46
+ public enum CollectionUserFlags
47
+ {
48
+ /// <summary>
49
+ /// No flags.
50
+ /// </summary>
51
+ None = 0 ,
52
+ /// <summary>
53
+ /// User power of 2 size.
54
+ /// </summary>
55
+ UsePowerOf2Size = 1
56
+ }
57
+
26
58
/// <summary>
27
59
/// Represents the results of the collection stats command.
28
60
/// </summary>
@@ -68,9 +100,22 @@ public int ExtentCount
68
100
/// <summary>
69
101
/// Gets the flags.
70
102
/// </summary>
103
+ [ Obsolete ( "Use SystemFlags or UserFlags instead." ) ]
71
104
public int Flags
72
105
{
73
- get { return Response [ "flags" ] . AsInt32 ; }
106
+ get
107
+ {
108
+ // flags was renamed to systemFlags in server version 2.2
109
+ BsonValue flags ;
110
+ if ( Response . TryGetValue ( "flags" , out flags ) || Response . TryGetValue ( "systemFlags" , out flags ) )
111
+ {
112
+ return flags . AsInt32 ;
113
+ }
114
+ else
115
+ {
116
+ return 0 ;
117
+ }
118
+ }
74
119
}
75
120
76
121
/// <summary>
@@ -153,6 +198,26 @@ public long StorageSize
153
198
get { return Response [ "storageSize" ] . ToInt64 ( ) ; }
154
199
}
155
200
201
+ /// <summary>
202
+ /// Gets the system flags.
203
+ /// </summary>
204
+ public CollectionSystemFlags SystemFlags
205
+ {
206
+ get
207
+ {
208
+ // systemFlags was called flags prior to server version 2.2
209
+ BsonValue systemFlags ;
210
+ if ( Response . TryGetValue ( "systemFlags" , out systemFlags ) || Response . TryGetValue ( "flags" , out systemFlags ) )
211
+ {
212
+ return ( CollectionSystemFlags ) systemFlags . AsInt32 ;
213
+ }
214
+ else
215
+ {
216
+ return CollectionSystemFlags . None ;
217
+ }
218
+ }
219
+ }
220
+
156
221
/// <summary>
157
222
/// Gets the total index size.
158
223
/// </summary>
@@ -161,6 +226,26 @@ public long TotalIndexSize
161
226
get { return Response [ "totalIndexSize" ] . ToInt64 ( ) ; }
162
227
}
163
228
229
+ /// <summary>
230
+ /// Gets the user flags.
231
+ /// </summary>
232
+ public CollectionUserFlags UserFlags
233
+ {
234
+ get
235
+ {
236
+ // userFlags was first introduced in server version 2.2
237
+ BsonValue userFlags ;
238
+ if ( Response . TryGetValue ( "userFlags" , out userFlags ) )
239
+ {
240
+ return ( CollectionUserFlags ) userFlags . AsInt32 ;
241
+ }
242
+ else
243
+ {
244
+ return CollectionUserFlags . None ;
245
+ }
246
+ }
247
+ }
248
+
164
249
// nested classes
165
250
/// <summary>
166
251
/// Represents a collection of index sizes.
0 commit comments