2323
2424namespace MongoDB . Driver
2525{
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+
2658 /// <summary>
2759 /// Represents the results of the collection stats command.
2860 /// </summary>
@@ -68,9 +100,22 @@ public int ExtentCount
68100 /// <summary>
69101 /// Gets the flags.
70102 /// </summary>
103+ [ Obsolete ( "Use SystemFlags or UserFlags instead." ) ]
71104 public int Flags
72105 {
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+ }
74119 }
75120
76121 /// <summary>
@@ -153,6 +198,26 @@ public long StorageSize
153198 get { return Response [ "storageSize" ] . ToInt64 ( ) ; }
154199 }
155200
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+
156221 /// <summary>
157222 /// Gets the total index size.
158223 /// </summary>
@@ -161,6 +226,26 @@ public long TotalIndexSize
161226 get { return Response [ "totalIndexSize" ] . ToInt64 ( ) ; }
162227 }
163228
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+
164249 // nested classes
165250 /// <summary>
166251 /// Represents a collection of index sizes.
0 commit comments