forked from PeterWaher/IoTGateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNullDatabaseProvider.cs
More file actions
417 lines (373 loc) · 16.9 KB
/
Copy pathNullDatabaseProvider.cs
File metadata and controls
417 lines (373 loc) · 16.9 KB
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Waher.Persistence.Filters;
using Waher.Persistence.Serialization;
namespace Waher.Persistence
{
/// <summary>
/// A NULL database.
/// </summary>
public class NullDatabaseProvider : IDatabaseProvider
{
/// <summary>
/// A NULL database.
/// </summary>
public NullDatabaseProvider()
{
}
/// <summary>
/// Inserts an object into the database.
/// </summary>
/// <param name="Object">Object to insert.</param>
public Task Insert(object Object) => Task.CompletedTask;
/// <summary>
/// Inserts a collection of objects into the database.
/// </summary>
/// <param name="Objects">Objects to insert.</param>
public Task Insert(params object[] Objects) => Task.CompletedTask;
/// <summary>
/// Inserts a collection of objects into the database.
/// </summary>
/// <param name="Objects">Objects to insert.</param>
public Task Insert(IEnumerable<object> Objects) => Task.CompletedTask;
/// <summary>
/// Finds objects of a given class <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">Class defining how to deserialize objects found.</typeparam>
/// <param name="Offset">Result offset.</param>
/// <param name="MaxCount">Maximum number of objects to return.</param>
/// <param name="SortOrder">Sort order. Each string represents a field name. By default, sort order is ascending.
/// If descending sort order is desired, prefix the field name by a hyphen (minus) sign.</param>
/// <returns>Objects found.</returns>
public Task<IEnumerable<T>> Find<T>(int Offset, int MaxCount, params string[] SortOrder)
where T : class
{
return Task.FromResult<IEnumerable<T>>(new T[0]);
}
/// <summary>
/// Finds objects of a given class <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">Class defining how to deserialize objects found.</typeparam>
/// <param name="Offset">Result offset.</param>
/// <param name="MaxCount">Maximum number of objects to return.</param>
/// <param name="Filter">Optional filter. Can be null.</param>
/// <param name="SortOrder">Sort order. Each string represents a field name. By default, sort order is ascending.
/// If descending sort order is desired, prefix the field name by a hyphen (minus) sign.</param>
/// <returns>Objects found.</returns>
public Task<IEnumerable<T>> Find<T>(int Offset, int MaxCount, Filter Filter, params string[] SortOrder)
where T : class
{
return Task.FromResult<IEnumerable<T>>(new T[0]);
}
/// <summary>
/// Finds objects in a given collection.
/// </summary>
/// <param name="Collection">Name of collection to search.</param>
/// <param name="Offset">Result offset.</param>
/// <param name="MaxCount">Maximum number of objects to return.</param>
/// <param name="SortOrder">Sort order. Each string represents a field name. By default, sort order is ascending.
/// If descending sort order is desired, prefix the field name by a hyphen (minus) sign.</param>
/// <returns>Objects found.</returns>
public Task<IEnumerable<object>> Find(string Collection, int Offset, int MaxCount, params string[] SortOrder)
{
return Task.FromResult<IEnumerable<object>>(new object[0]);
}
/// <summary>
/// Finds objects in a given collection.
/// </summary>
/// <param name="Collection">Name of collection to search.</param>
/// <param name="Offset">Result offset.</param>
/// <param name="MaxCount">Maximum number of objects to return.</param>
/// <param name="Filter">Optional filter. Can be null.</param>
/// <param name="SortOrder">Sort order. Each string represents a field name. By default, sort order is ascending.
/// If descending sort order is desired, prefix the field name by a hyphen (minus) sign.</param>
/// <returns>Objects found.</returns>
public Task<IEnumerable<object>> Find(string Collection, int Offset, int MaxCount, Filter Filter, params string[] SortOrder)
{
return Task.FromResult<IEnumerable<object>>(new object[0]);
}
/// <summary>
/// Updates an object in the database.
/// </summary>
/// <param name="Object">Object to insert.</param>
public Task Update(object Object) => Task.CompletedTask;
/// <summary>
/// Updates a collection of objects in the database.
/// </summary>
/// <param name="Objects">Objects to insert.</param>
public Task Update(params object[] Objects) => Task.CompletedTask;
/// <summary>
/// Updates a collection of objects in the database.
/// </summary>
/// <param name="Objects">Objects to insert.</param>
public Task Update(IEnumerable<object> Objects) => Task.CompletedTask;
/// <summary>
/// Deletes an object in the database.
/// </summary>
/// <param name="Object">Object to insert.</param>
public Task Delete(object Object) => Task.CompletedTask;
/// <summary>
/// Deletes a collection of objects in the database.
/// </summary>
/// <param name="Objects">Objects to insert.</param>
public Task Delete(params object[] Objects) => Task.CompletedTask;
/// <summary>
/// Deletes a collection of objects in the database.
/// </summary>
/// <param name="Objects">Objects to insert.</param>
public Task Delete(IEnumerable<object> Objects) => Task.CompletedTask;
/// <summary>
/// Finds objects of a given class <typeparamref name="T"/> and deletes them in the same atomic operation.
/// </summary>
/// <typeparam name="T">Class defining how to deserialize objects found.</typeparam>
/// <param name="Offset">Result offset.</param>
/// <param name="MaxCount">Maximum number of objects to return.</param>
/// <param name="SortOrder">Sort order. Each string represents a field name. By default, sort order is ascending.
/// If descending sort order is desired, prefix the field name by a hyphen (minus) sign.</param>
/// <returns>Objects found.</returns>
public Task<IEnumerable<T>> FindDelete<T>(int Offset, int MaxCount, params string[] SortOrder)
where T : class
{
return Task.FromResult<IEnumerable<T>>(new T[0]);
}
/// <summary>
/// Finds objects of a given class <typeparamref name="T"/> and deletes them in the same atomic operation.
/// </summary>
/// <typeparam name="T">Class defining how to deserialize objects found.</typeparam>
/// <param name="Offset">Result offset.</param>
/// <param name="MaxCount">Maximum number of objects to return.</param>
/// <param name="Filter">Optional filter. Can be null.</param>
/// <param name="SortOrder">Sort order. Each string represents a field name. By default, sort order is ascending.
/// If descending sort order is desired, prefix the field name by a hyphen (minus) sign.</param>
/// <returns>Objects found.</returns>
public Task<IEnumerable<T>> FindDelete<T>(int Offset, int MaxCount, Filter Filter, params string[] SortOrder)
where T : class
{
return Task.FromResult<IEnumerable<T>>(new T[0]);
}
/// <summary>
/// Finds objects in a given collection and deletes them in the same atomic operation.
/// </summary>
/// <param name="Collection">Name of collection to search.</param>
/// <param name="Offset">Result offset.</param>
/// <param name="MaxCount">Maximum number of objects to return.</param>
/// <param name="SortOrder">Sort order. Each string represents a field name. By default, sort order is ascending.
/// If descending sort order is desired, prefix the field name by a hyphen (minus) sign.</param>
/// <returns>Objects found.</returns>
public Task<IEnumerable<object>> FindDelete(string Collection, int Offset, int MaxCount, params string[] SortOrder)
{
return Task.FromResult<IEnumerable<object>>(new object[0]);
}
/// <summary>
/// Finds objects in a given collection and deletes them in the same atomic operation.
/// </summary>
/// <param name="Collection">Name of collection to search.</param>
/// <param name="Offset">Result offset.</param>
/// <param name="MaxCount">Maximum number of objects to return.</param>
/// <param name="Filter">Optional filter. Can be null.</param>
/// <param name="SortOrder">Sort order. Each string represents a field name. By default, sort order is ascending.
/// If descending sort order is desired, prefix the field name by a hyphen (minus) sign.</param>
/// <returns>Objects found.</returns>
public Task<IEnumerable<object>> FindDelete(string Collection, int Offset, int MaxCount, Filter Filter, params string[] SortOrder)
{
return Task.FromResult<IEnumerable<object>>(new object[0]);
}
/// <summary>
/// Tries to load an object given its Object ID <paramref name="ObjectId"/> and its class type <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">Base type.</typeparam>
/// <param name="ObjectId">Object ID</param>
/// <returns>Loaded object, or null if not found.</returns>
public Task<T> TryLoadObject<T>(object ObjectId)
where T : class
{
return default;
}
/// <summary>
/// Tries to load an object given its Object ID <paramref name="ObjectId"/> and its class type <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">Base type.</typeparam>
/// <param name="CollectionName">Name of collection in which the object resides.</param>
/// <param name="ObjectId">Object ID</param>
/// <returns>Loaded object, or null if not found.</returns>
public Task<T> TryLoadObject<T>(string CollectionName, object ObjectId)
where T : class
{
return default;
}
/// <summary>
/// Tries to load an object given its Object ID <paramref name="ObjectId"/> and its collection name <paramref name="CollectionName"/>.
/// </summary>
/// <param name="CollectionName">Name of collection in which the object resides.</param>
/// <param name="ObjectId">Object ID</param>
/// <returns>Loaded object, or null if not found.</returns>
public Task<object> TryLoadObject(string CollectionName, object ObjectId)
{
return null;
}
/// <summary>
/// Performs an export of the entire database.
/// </summary>
/// <param name="Output">Database will be output to this interface.</param>
/// <param name="CollectionNames">Optional array of collections to export. If null, all collections will be exported.</param>
/// <returns>public Task object for synchronization purposes.</returns>
public Task Export(IDatabaseExport Output, string[] CollectionNames) => Task.CompletedTask;
/// <summary>
/// Clears a collection of all objects.
/// </summary>
/// <param name="CollectionName">Name of collection to clear.</param>
/// <returns>public Task object for synchronization purposes.</returns>
public Task Clear(string CollectionName) => Task.CompletedTask;
/// <summary>
/// Analyzes the database and exports findings to XML.
/// </summary>
/// <param name="Output">XML Output.</param>
/// <param name="XsltPath">Optional XSLT to use to view the output.</param>
/// <param name="ProgramDataFolder">Program data folder. Can be removed from filenames used, when referencing them in the report.</param>
/// <param name="ExportData">If data in database is to be exported in output.</param>
/// <returns>Collections with errors found.</returns>
public Task<string[]> Analyze(XmlWriter Output, string XsltPath, string ProgramDataFolder, bool ExportData)
{
return Task.FromResult<string[]>(new string[0]);
}
/// <summary>
/// Analyzes the database and repairs it if necessary. Results are exported to XML.
/// </summary>
/// <param name="Output">XML Output.</param>
/// <param name="XsltPath">Optional XSLT to use to view the output.</param>
/// <param name="ProgramDataFolder">Program data folder. Can be removed from filenames used, when referencing them in the report.</param>
/// <param name="ExportData">If data in database is to be exported in output.</param>
/// <returns>Collections with errors found and repaired.</returns>
public Task<string[]> Repair(XmlWriter Output, string XsltPath, string ProgramDataFolder, bool ExportData)
{
return Task.FromResult<string[]>(new string[0]);
}
/// <summary>
/// Analyzes the database and exports findings to XML.
/// </summary>
/// <param name="Output">XML Output.</param>
/// <param name="XsltPath">Optional XSLT to use to view the output.</param>
/// <param name="ProgramDataFolder">Program data folder. Can be removed from filenames used, when referencing them in the report.</param>
/// <param name="ExportData">If data in database is to be exported in output.</param>
/// <param name="Repair">If files should be repaired if corruptions are detected.</param>
/// <returns>Collections with errors found, and repaired if <paramref name="Repair"/>=true.</returns>
public Task<string[]> Analyze(XmlWriter Output, string XsltPath, string ProgramDataFolder, bool ExportData, bool Repair)
{
return Task.FromResult<string[]>(new string[0]);
}
/// <summary>
/// Repairs a set of collections.
/// </summary>
/// <param name="CollectionNames">Set of collections to repair.</param>
/// <returns>Collections repaired.</returns>
public Task<string[]> Repair(params string[] CollectionNames)
{
return Task.FromResult<string[]>(new string[0]);
}
/// <summary>
/// Adds an index to a collection, if one does not already exist.
/// </summary>
/// <param name="CollectionName">Name of collection.</param>
/// <param name="FieldNames">Sort order. Each string represents a field name. By default, sort order is ascending.
/// If descending sort order is desired, prefix the field name by a hyphen (minus) sign.</param>
public Task AddIndex(string CollectionName, string[] FieldNames) => Task.CompletedTask;
/// <summary>
/// Removes an index from a collection, if one exist.
/// </summary>
/// <param name="CollectionName">Name of collection.</param>
/// <param name="FieldNames">Sort order. Each string represents a field name. By default, sort order is ascending.
/// If descending sort order is desired, prefix the field name by a hyphen (minus) sign.</param>
public Task RemoveIndex(string CollectionName, string[] FieldNames) => Task.CompletedTask;
/// <summary>
/// Starts bulk-proccessing of data. Must be followed by a call to <see cref="EndBulk"/>.
/// </summary>
public Task StartBulk() => Task.CompletedTask;
/// <summary>
/// Ends bulk-processing of data. Must be called once for every call to <see cref="StartBulk"/>.
/// </summary>
public Task EndBulk() => Task.CompletedTask;
/// <summary>
/// Called when processing starts.
/// </summary>
public Task Start() => Task.CompletedTask;
/// <summary>
/// Called when processing ends.
/// </summary>
public Task Stop() => Task.CompletedTask;
/// <summary>
/// Persists any pending changes.
/// </summary>
public Task Flush() => Task.CompletedTask;
/// <summary>
/// Number of bytes used by an Object ID.
/// </summary>
public int ObjectIdByteCount => 0;
/// <summary>
/// Gets a persistent dictionary containing objects in a collection.
/// </summary>
/// <param name="Collection">Collection Name</param>
/// <returns>Persistent dictionary</returns>
public Task<IPersistentDictionary> GetDictionary(string Collection) => throw new InvalidOperationException("Server is shutting down.");
/// <summary>
/// Gets an array of available collections.
/// </summary>
/// <returns>Array of collections.</returns>
public Task<string[]> GetCollections()
{
return Task.FromResult<string[]>(new string[0]);
}
/// <summary>
/// Gets the collection corresponding to a given type.
/// </summary>
/// <param name="Type">Type</param>
/// <returns>Collection name.</returns>
public Task<string> GetCollection(Type Type)
{
return Task.FromResult<string>(string.Empty);
}
/// <summary>
/// Gets the collection corresponding to a given object.
/// </summary>
/// <param name="Object">Object</param>
/// <returns>Collection name.</returns>
public Task<string> GetCollection(Object Object)
{
return Task.FromResult<string>(string.Empty);
}
/// <summary>
/// Checks if a string is a label in a given collection.
/// </summary>
/// <param name="Collection">Name of collection.</param>
/// <param name="Label">Label to check.</param>
/// <returns>If <paramref name="Label"/> is a label in the collection
/// defined by <paramref name="Collection"/>.</returns>
public Task<bool> IsLabel(string Collection, string Label)
{
return Task.FromResult<bool>(false);
}
/// <summary>
/// Gets an array of available labels for a collection.
/// </summary>
/// <returns>Array of labels.</returns>
public Task<string[]> GetLabels(string Collection)
{
return Task.FromResult<string[]>(new string[0]);
}
/// <summary>
/// Tries to get the Object ID of an object, if it exists.
/// </summary>
/// <param name="Object">Object whose Object ID is of interest.</param>
/// <returns>Object ID, if found, null otherwise.</returns>
public Task<object> TryGetObjectId(object Object)
{
return Task.FromResult<object>(null);
}
/// <summary>
/// Drops a collection, if it exist.
/// </summary>
/// <param name="CollectionName">Name of collection.</param>
public Task DropCollection(string CollectionName) => Task.CompletedTask;
}
}