4using System.Threading.Tasks;
22 private static readonly Dictionary<string, Dictionary<string, FlagSource>> toRepair =
new Dictionary<string, Dictionary<string, FlagSource>>();
24 private static bool locked =
false;
48 if (!(provider is
null) && locked)
49 throw new Exception(
"A database provider is already registered.");
51 provider = DatabaseProvider;
62 if (!(provider is
null))
65 throw new Exception(
"A database provider has not been registered.");
90 get {
return locked; }
97 public async
static Task
Insert(
object Object)
100 RaiseInserted(Object);
103 private static void RaiseInserted(
object Object)
108 private static void RaiseInserted(IEnumerable<object> Objects)
110 foreach (
object Object
in Objects)
111 RaiseInserted(Object);
123 public async
static Task
Insert(params
object[] Objects)
125 if (Objects.Length == 1)
130 RaiseInserted(Objects);
137 public async
static Task
Insert(IEnumerable<object> Objects)
140 RaiseInserted(Objects);
158 if (Objects.Length == 1)
168 public static async Task
InsertLazy(IEnumerable<object> Objects)
180 public static Task<IEnumerable<T>>
Find<T>(params
string[] SortOrder)
209 public static Task<IEnumerable<T>>
Find<T>(
int Offset,
int MaxCount, params
string[] SortOrder)
225 public static Task<IEnumerable<T>>
Find<T>(
int Offset,
int MaxCount,
Filter Filter, params
string[] SortOrder)
238 public static Task<IEnumerable<object>>
Find(
string Collection, params
string[] SortOrder)
240 return Provider.
Find(Collection, 0,
int.MaxValue, SortOrder);
251 public static Task<IEnumerable<object>>
Find(
string Collection,
Filter Filter, params
string[] SortOrder)
265 public static Task<IEnumerable<object>>
Find(
string Collection,
int Offset,
int MaxCount, params
string[] SortOrder)
267 return Provider.
Find(Collection, Offset, MaxCount, SortOrder);
280 public static Task<IEnumerable<object>>
Find(
string Collection,
int Offset,
int MaxCount,
Filter Filter, params
string[] SortOrder)
293 public static Task<IEnumerable<T>>
Find<T>(
string Collection,
string[] SortOrder)
296 return Provider.
Find<T>(Collection, 0,
int.MaxValue,
null, SortOrder);
324 public static Task<IEnumerable<T>>
Find<T>(
string Collection,
int Offset,
int MaxCount, params
string[] SortOrder)
327 return Provider.
Find<T>(Collection, Offset, MaxCount,
null, SortOrder);
341 public static Task<IEnumerable<T>>
Find<T>(
string Collection,
int Offset,
int MaxCount,
Filter Filter, params
string[] SortOrder)
355 public static Task<IPage<T>>
FindFirst<T>(
int PageSize, params
string[] SortOrder)
385 public static Task<IPage<object>>
FindFirst(
string Collection,
int PageSize, params
string[] SortOrder)
399 public static Task<IPage<object>>
FindFirst(
string Collection,
int PageSize,
Filter Filter, params
string[] SortOrder)
452 public static async Task<PaginatedEnumerator<T>>
Enumerate<T>(
int PageSize, params
string[] SortOrder)
482 public static async Task<PaginatedEnumerator<object>>
Enumerate(
string Collection,
int PageSize, params
string[] SortOrder)
496 public static async Task<PaginatedEnumerator<object>>
Enumerate(
string Collection,
int PageSize,
Filter Filter, params
string[] SortOrder)
511 public static async Task<PaginatedEnumerator<T>>
Enumerate<T>(
string Collection,
int PageSize,
Filter Filter, params
string[] SortOrder)
528 return await FirstDeleteRest(await
Provider.
Find<T>(0,
int.MaxValue, SortOrder));
531 private static async Task<T> FirstDeleteRest<T>(IEnumerable<T> Set)
537 foreach (T Obj
in Set)
550 catch (KeyNotFoundException)
572 return await FirstDeleteRest(await
Provider.
Find<T>(0,
int.MaxValue,
Filter, SortOrder));
586 return FirstIgnoreRest(await
Provider.
Find<T>(0, 1, SortOrder));
589 private static T FirstIgnoreRest<T>(IEnumerable<T> Set)
592 foreach (T Obj
in Set)
690 return Provider.
Process(Processor, Collection, 0,
int.MaxValue, SortOrder);
721 return Provider.
Process(Processor, Collection, Offset, MaxCount, SortOrder);
754 return Provider.
Process(Processor, Collection, 0,
int.MaxValue,
null, SortOrder);
786 public static Task<bool>
Process<T>(
IProcessor<T> Processor,
string Collection,
int Offset,
int MaxCount, params
string[] SortOrder)
789 return Provider.
Process(Processor, Collection, Offset, MaxCount,
null, SortOrder);
820 public static Task<bool>
Process<T>(Predicate<T> Processor, params
string[] SortOrder)
853 public static Task<bool>
Process<T>(Predicate<T> Processor,
int Offset,
int MaxCount, params
string[] SortOrder)
871 public static Task<bool>
Process<T>(Predicate<T> Processor,
int Offset,
int MaxCount,
Filter Filter, params
string[] SortOrder)
886 public static Task<bool>
Process(Predicate<object> Processor,
string Collection, params
string[] SortOrder)
901 public static Task<bool>
Process(Predicate<object> Processor,
string Collection,
Filter Filter, params
string[] SortOrder)
917 public static Task<bool>
Process(Predicate<object> Processor,
string Collection,
int Offset,
int MaxCount, params
string[] SortOrder)
934 public static Task<bool>
Process(Predicate<object> Processor,
string Collection,
int Offset,
int MaxCount,
Filter Filter, params
string[] SortOrder)
949 public static Task<bool>
Process<T>(Predicate<T> Processor,
string Collection,
string[] SortOrder)
984 public static Task<bool>
Process<T>(Predicate<T> Processor,
string Collection,
int Offset,
int MaxCount, params
string[] SortOrder)
1003 public static Task<bool>
Process<T>(Predicate<T> Processor,
string Collection,
int Offset,
int MaxCount,
Filter Filter, params
string[] SortOrder)
1018 public static Task<bool>
Process<T>(PredicateAsync<T> Processor, params
string[] SortOrder)
1051 public static Task<bool>
Process<T>(PredicateAsync<T> Processor,
int Offset,
int MaxCount, params
string[] SortOrder)
1069 public static Task<bool>
Process<T>(PredicateAsync<T> Processor,
int Offset,
int MaxCount,
Filter Filter, params
string[] SortOrder)
1084 public static Task<bool>
Process(PredicateAsync<object> Processor,
string Collection, params
string[] SortOrder)
1099 public static Task<bool>
Process(PredicateAsync<object> Processor,
string Collection,
Filter Filter, params
string[] SortOrder)
1115 public static Task<bool>
Process(PredicateAsync<object> Processor,
string Collection,
int Offset,
int MaxCount, params
string[] SortOrder)
1132 public static Task<bool>
Process(PredicateAsync<object> Processor,
string Collection,
int Offset,
int MaxCount,
Filter Filter, params
string[] SortOrder)
1147 public static Task<bool>
Process<T>(PredicateAsync<T> Processor,
string Collection,
string[] SortOrder)
1164 public static Task<bool>
Process<T>(PredicateAsync<T> Processor,
string Collection,
Filter Filter, params
string[] SortOrder)
1182 public static Task<bool>
Process<T>(PredicateAsync<T> Processor,
string Collection,
int Offset,
int MaxCount, params
string[] SortOrder)
1201 public static Task<bool>
Process<T>(PredicateAsync<T> Processor,
string Collection,
int Offset,
int MaxCount,
Filter Filter, params
string[] SortOrder)
1211 public async
static Task
Update(
object Object)
1214 RaiseUpdated(Object);
1217 private static void RaiseUpdated(
object Object)
1222 private static void RaiseUpdated(IEnumerable<object> Objects)
1224 foreach (
object Object
in Objects)
1225 RaiseUpdated(Object);
1237 public async
static Task
Update(params
object[] Objects)
1239 if (Objects.Length == 1)
1244 RaiseUpdated(Objects);
1251 public async
static Task
Update(IEnumerable<object> Objects)
1254 RaiseUpdated(Objects);
1272 if (Objects.Length == 1)
1291 public async
static Task
Delete(
object Object)
1294 RaiseDeleted(Object);
1306 public async
static Task
Delete(params
object[] Objects)
1308 if (Objects.Length == 1)
1313 RaiseDeleted(Objects);
1320 public async
static Task
Delete(IEnumerable<object> Objects)
1323 RaiseDeleted(Objects);
1341 if (Objects.Length == 1)
1356 private static void RaiseDeleted(
object Object)
1361 private static void RaiseDeleted(IEnumerable<object> Objects)
1363 foreach (
object Object
in Objects)
1364 RaiseDeleted(Object);
1389 public static async Task<IEnumerable<T>>
FindDelete<T>(
int Offset,
int MaxCount, params
string[] SortOrder)
1394 foreach (T Object
in Result)
1395 RaiseDeleted(Object);
1429 foreach (T Object
in Result)
1430 RaiseDeleted(Object);
1442 public static Task<IEnumerable<object>>
FindDelete(
string Collection, params
string[] SortOrder)
1444 return FindDelete(Collection, 0,
int.MaxValue, SortOrder);
1456 public static async Task<IEnumerable<object>>
FindDelete(
string Collection,
int Offset,
int MaxCount, params
string[] SortOrder)
1458 IEnumerable<object> Result = await
Provider.
FindDelete(Collection, Offset, MaxCount, SortOrder);
1460 foreach (
object Object
in Result)
1461 RaiseDeleted(Object);
1489 public static async Task<IEnumerable<object>>
FindDelete(
string Collection,
int Offset,
int MaxCount,
Filter Filter, params
string[] SortOrder)
1493 foreach (
object Object
in Result)
1494 RaiseDeleted(Object);
1506 public static Task<int>
Delete<T>(params
string[] SortOrder)
1509 return Delete<T>(0,
int.MaxValue, SortOrder);
1521 public static async Task<int>
Delete<T>(
int Offset,
int MaxCount, params
string[] SortOrder)
1531 MaxCount2 = Math.Min(MaxCount, 1000);
1535 foreach (T Object
in Result)
1537 RaiseDeleted(Object);
1543 while (Found && MaxCount > 0);
1582 MaxCount2 = Math.Min(MaxCount, 1000);
1586 foreach (T Object
in Result)
1588 RaiseDeleted(Object);
1594 while (Found && MaxCount > 0);
1606 public static Task<int>
Delete(
string Collection, params
string[] SortOrder)
1608 return Delete(Collection, 0,
int.MaxValue, SortOrder);
1620 public static async Task<int>
Delete(
string Collection,
int Offset,
int MaxCount, params
string[] SortOrder)
1629 MaxCount2 = Math.Min(MaxCount, 1000);
1631 IEnumerable<object> Result = await
Provider.
FindDelete(Collection, Offset, MaxCount2, SortOrder);
1633 foreach (
object Object
in Result)
1635 RaiseDeleted(Object);
1641 while (Found && MaxCount > 0);
1656 return Delete(Collection, 0,
int.MaxValue,
Filter, SortOrder);
1669 public static async Task<int>
Delete(
string Collection,
int Offset,
int MaxCount,
Filter Filter, params
string[] SortOrder)
1678 MaxCount2 = Math.Min(MaxCount, 1000);
1682 foreach (
object Object
in Result)
1684 RaiseDeleted(Object);
1690 while (Found && MaxCount > 0);
1717 public static Task
DeleteLazy<T>(
int Offset,
int MaxCount, params
string[] SortOrder)
1760 public static Task
DeleteLazy(
string Collection, params
string[] SortOrder)
1762 return DeleteLazy(Collection, 0,
int.MaxValue, SortOrder);
1774 public static Task
DeleteLazy(
string Collection,
int Offset,
int MaxCount, params
string[] SortOrder)
1838 public static Task<object>
TryLoadObject(
string CollectionName,
object ObjectId)
1853 ??
throw new KeyNotFoundException(
"Object not found.");
1865 public async
static Task<T>
LoadObject<T>(
string CollectionName,
object ObjectId)
1869 ??
throw new KeyNotFoundException(
"Object not found.");
1880 public static async Task<object>
LoadObject(
string CollectionName,
object ObjectId)
1883 ??
throw new KeyNotFoundException(
"Object not found.");
1895 return Export(Output,
null);
1930 return Iterate(Recipient,
null);
1943 return Provider.Iterate(Recipient, CollectionNames);
1957 return Provider.Iterate(Recipient, CollectionNames, Thread);
1965 public async
static Task
Clear(
string CollectionName)
1985 public static Task<string[]>
Analyze(XmlWriter Output,
string XsltPath,
string ProgramDataFolder,
bool ExportData)
1987 return Provider.
Analyze(Output, XsltPath, ProgramDataFolder, ExportData);
1999 public static Task<string[]>
Analyze(XmlWriter Output,
string XsltPath,
string ProgramDataFolder,
bool ExportData,
2002 return Provider.
Analyze(Output, XsltPath, ProgramDataFolder, ExportData, Thread);
2013 public static Task<string[]>
Repair(XmlWriter Output,
string XsltPath,
string ProgramDataFolder,
bool ExportData)
2015 return Repair(Output, XsltPath, ProgramDataFolder, ExportData,
null);
2027 public async
static Task<string[]>
Repair(XmlWriter Output,
string XsltPath,
string ProgramDataFolder,
bool ExportData,
2030 KeyValuePair<string, Dictionary<string, FlagSource>>[] Flagged = GetFlaggedCollections();
2032 string[] Result = await
Provider.
Repair(Output, XsltPath, ProgramDataFolder, ExportData, Thread);
2034 if (Result.Length > 0)
2035 await RaiseRepaired(Result, Flagged);
2040 private static async Task RaiseRepaired(
string[] Collections, KeyValuePair<
string, Dictionary<string, FlagSource>>[] Flagged)
2049 foreach (
string Collection
in Collections)
2051 FlaggedCollection =
null;
2053 if (!(Flagged is
null))
2055 foreach (KeyValuePair<
string, Dictionary<string, FlagSource>> Rec
in Flagged)
2057 if (Rec.Key == Collection)
2059 FlaggedCollection =
new FlagSource[Rec.Value.Count];
2060 Rec.Value.Values.CopyTo(FlaggedCollection, 0);
2070 catch (Exception ex)
2090 public static Task<string[]>
Analyze(XmlWriter Output,
string XsltPath,
string ProgramDataFolder,
bool ExportData,
2093 return Analyze(Output, XsltPath, ProgramDataFolder, ExportData,
Repair,
null);
2106 public async
static Task<string[]>
Analyze(XmlWriter Output,
string XsltPath,
string ProgramDataFolder,
bool ExportData,
2109 KeyValuePair<string, Dictionary<string, FlagSource>>[] Flagged = GetFlaggedCollections();
2111 string[] Result = await
Provider.
Analyze(Output, XsltPath, ProgramDataFolder, ExportData,
Repair, Thread);
2113 if (
Repair && Result.Length > 0)
2114 await RaiseRepaired(Result, Flagged);
2119 private static KeyValuePair<string, Dictionary<string, FlagSource>>[] GetFlaggedCollections()
2121 KeyValuePair<string, Dictionary<string, FlagSource>>[] Flagged;
2126 Flagged =
new KeyValuePair<string, Dictionary<string, FlagSource>>[toRepair.Count];
2129 foreach (KeyValuePair<
string, Dictionary<string, FlagSource>> P
in toRepair)
2148 Result =
new string[toRepair.Count];
2149 toRepair.Keys.CopyTo(Result, 0);
2163 toRepair[Collection] =
null;
2175 toRepair.Remove(Collection);
2186 if (!
string.IsNullOrEmpty(Collection))
2190 string Key = Reason +
" | " + StackTrace;
2194 if (toRepair.TryGetValue(Collection, out Dictionary<string, FlagSource> PerStackTrace))
2196 if (!(PerStackTrace is
null))
2201 PerStackTrace[Key] =
new FlagSource(Reason, StackTrace, 1);
2205 toRepair[Collection] =
new Dictionary<string, FlagSource>() { { Key,
new FlagSource(Reason, StackTrace, 1) } };
2211 return new Exception(Reason);
2220 public static Task
AddIndex(
string CollectionName,
string[] FieldNames)
2231 public static Task
RemoveIndex(
string CollectionName,
string[] FieldNames)
2275 string[] B =
new string[c];
2277 for (i = 0; i < c; i++)
2296 for (i = 0; i < c; i++)
2326 public static Task<IPersistedQueue>
GetQueue(
string QueueName)
2337 public static Task<IPersistedQueue>
GetQueue(
string QueueName,
bool CanBeNull)
2387 public static Task<bool>
IsLabel(
string Collection,
string Label)
2428 string[] Parts = s.Split(
new string[] { Wildcard }, StringSplitOptions.None);
2429 StringBuilder RegEx =
new StringBuilder();
2433 foreach (
string Part
in Parts)
2444 j = Part.IndexOfAny(regexSpecialCharaters, i);
2447 RegEx.Append(Part.Substring(i));
2453 RegEx.Append(Part.Substring(i, j - i));
2456 RegEx.Append(Part[j]);
2463 return RegEx.ToString();
2466 private static readonly
char[] regexSpecialCharaters =
new char[] {
'\\',
'^',
'$',
'{',
'}',
'[',
']',
'(',
')',
'.',
'*',
'+',
'?',
'|',
'<',
'>',
'-',
'&' };
Static class managing the application event log. Applications and services log events on this static ...
static string CleanStackTrace(string StackTrace)
Cleans a Stack Trace string, removing entries from the asynchronous execution model,...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Represents a case-insensitive string.
int Length
Gets the number of characters in the current CaseInsensitiveString object.
Event arguments for collection events.
Event arguments for collection repaired events.
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static Task< bool > Process(Predicate< object > Processor, string Collection, Filter Filter, params string[] SortOrder)
Processes objects in a given collection.
static Task< string[]> GetDictionaries()
Gets an array of available dictionary collections.
static Task< IEnumerable< object > > FindDelete(string Collection, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static Task< string[]> Analyze(XmlWriter Output, string XsltPath, string ProgramDataFolder, bool ExportData, ProfilerThread Thread)
Analyzes the database and exports findings to XML.
static Task< T > TryLoadObject< T >(object ObjectId)
Tries to load an object given its Object ID ObjectId and its class type T .
static Task< int > Delete(string Collection, Filter Filter, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static Task< string > GetCollection(Object Object)
Gets the collection corresponding to a given object.
static Task< IEnumerable< T > > Find< T >(params string[] SortOrder)
Finds objects of a given class T .
static Task DeleteLazy(string Collection, Filter Filter, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static Task< bool > Process(IProcessor< object > Processor, string Collection, int Offset, int MaxCount, Filter Filter, params string[] SortOrder)
Processes objects in a given collection.
static Task< IPage< T > > FindNext< T >(IPage< T > Page)
Finds the next page of objects of a given class T .
static Task< bool > Export(IDatabaseExport Output, string[] CollectionNames)
Performs an export of the database.
static async Task< IEnumerable< object > > FindDelete(string Collection, int Offset, int MaxCount, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static Task DeleteLazy(string Collection, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static async Task DeleteLazy(object Object)
Deletes an object in the database, if unlocked. If locked, object will be deleted at next opportunity...
static Task RemoveIndex(string CollectionName, string[] FieldNames)
Removes an index from a collection, if one exist.
static Task< IPersistentDictionary > GetDictionary(string Collection)
Gets a persistent dictionary containing objects in a collection.
static async Task< string[]> Analyze(XmlWriter Output, string XsltPath, string ProgramDataFolder, bool ExportData, bool Repair, ProfilerThread Thread)
Analyzes the database and exports findings to XML.
static Task DeleteLazy< T >(params string[] SortOrder)
Finds objects of a given class T and deletes them in the same atomic operation.
static Task< IEnumerable< object > > Find(string Collection, Filter Filter, params string[] SortOrder)
Finds objects in a given collection.
static Task< IEnumerable< T > > FindDelete< T >(params string[] SortOrder)
Finds objects of a given class T and deletes them in the same atomic operation.
static void EndRepair(string Collection)
Is called when reparation of a collection is ended.
static Task EndBulk()
Ends bulk-processing of data. Must be called once for every call to StartBulk.
static Task< bool > Process(PredicateAsync< object > Processor, string Collection, Filter Filter, params string[] SortOrder)
Processes objects in a given collection.
static bool HasProvider
If a database provider is registered.
static Task< string[]> Analyze(XmlWriter Output, string XsltPath, string ProgramDataFolder, bool ExportData)
Analyzes the database and exports findings to XML.
static async Task< int > Delete(string Collection, int Offset, int MaxCount, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static Task< bool > Process(IProcessor< object > Processor, string Collection, Filter Filter, params string[] SortOrder)
Processes objects in a given collection.
static Task< string[]> Repair(XmlWriter Output, string XsltPath, string ProgramDataFolder, bool ExportData)
Analyzes the database and repairs it if necessary. Results are exported to XML.
static CaseInsensitiveString[] ToCaseInsensitiveStringArray(this string[] A)
Converts a case insensitive string array to a normal string array.
static Task< int > Delete< T >(params string[] SortOrder)
Finds objects of a given class T and deletes them in the same atomic operation.
static EventHandler< ObjectEventArgs > ObjectInserted
Event raised when an object has been inserted.
static EventHandler< ObjectEventArgs > ObjectDeleted
Event raised when an object has been deleted.
static async Task< T > FindFirstIgnoreRest< T >(params string[] SortOrder)
Finds the first object of a given class T and ignores the rest.
static Task< bool > Process(IProcessor< object > Processor, string Collection, params string[] SortOrder)
Processes objects in a given collection.
static Task Iterate< T >(IDatabaseIteration< T > Recipient)
Performs an iteration of contents of the entire database.
static Task< bool > IsLabel(string Collection, string Label)
Checks if a string is a label in a given collection.
static string[] GetExcludedCollections()
Gets an array of collections that should be excluded from backups.
static Task< object > TryGetObjectId(object Object)
Tries to get the Object ID of an object, if it exists.
static async Task InsertLazy(object Object)
Inserts an object into the database, if unlocked. If locked, object will be inserted at next opportun...
static void Register(IDatabaseProvider DatabaseProvider)
Registers a database provider for use from the static Database class, throughout the lifetime of the ...
static EventHandlerAsync< CollectionEventArgs > CollectionCleared
Event raised when a collection has been cleared.
static Task DeleteLazy(string Collection, int Offset, int MaxCount, Filter Filter, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static EventHandler< ObjectEventArgs > ObjectUpdated
Event raised when an object has been updated.
static IDatabaseProvider Provider
Registered database provider.
static Task< bool > Process(PredicateAsync< object > Processor, string Collection, params string[] SortOrder)
Processes objects in a given collection.
static Task< IPage< object > > FindNext(IPage< object > Page)
Finds the next page of objects in a given collection.
static async Task Update(params object[] Objects)
Updates a collection of objects in the database.
static Task< IEnumerable< object > > Find(string Collection, int Offset, int MaxCount, Filter Filter, params string[] SortOrder)
Finds objects in a given collection.
static async Task Update(IEnumerable< object > Objects)
Updates a collection of objects in the database.
static Task DeleteLazy(string Collection, int Offset, int MaxCount, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static Task AddIndex(string CollectionName, string[] FieldNames)
Adds an index to a collection, if one does not already exist.
static string WildcardToRegex(string s, string Wildcard)
Converts a wildcard string to a regular expression string.
static Task< string[]> GetCollections()
Gets an array of available collections.
static Task< bool > Export(IDatabaseExport Output)
Performs an export of the database.
static Exception FlagForRepair(string Collection, string Reason)
Flags a collection for repairing.
static Task< IPage< object > > FindFirst(string Collection, int PageSize, params string[] SortOrder)
Finds the first page of objects in a given collection.
static async Task< int > Delete(string Collection, int Offset, int MaxCount, Filter Filter, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static Task StartBulk()
Starts bulk-proccessing of data. Must be followed by a call to EndBulk.
static Task< int > Delete(string Collection, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static EventHandlerAsync< CollectionRepairedEventArgs > CollectionRepaired
Event raised when a collection has been repaired.
static Task< bool > Process< T >(IProcessor< T > Processor, params string[] SortOrder)
Processes objects of a given class T .
static async Task Delete(IEnumerable< object > Objects)
Deletes a collection of objects in the database.
static void BeginRepair(string Collection)
Is called when reparation of a collection is begin.
static Task< IEnumerable< object > > Find(string Collection, int Offset, int MaxCount, params string[] SortOrder)
Finds objects in a given collection.
static Task< bool > Process(IProcessor< object > Processor, string Collection, int Offset, int MaxCount, params string[] SortOrder)
Processes objects in a given collection.
static async Task< PaginatedEnumerator< T > > Enumerate< T >(int PageSize, params string[] SortOrder)
Enumerates objects of a given class T available in the database, by retrieving items from the databa...
static async Task UpdateLazy(object Object)
Updates an object in the database, if unlocked. If locked, object will be updated at next opportunity...
static async Task UpdateLazy(IEnumerable< object > Objects)
Updates a collection of objects in the database, if unlocked. If locked, objects will be updated at n...
static bool Locked
If the datbase provider has been locked for the rest of the run-time of the application.
static Task< bool > Export(IDatabaseExport Output, string[] CollectionNames, ProfilerThread Thread)
Performs an export of the database.
static Task< string[]> Analyze(XmlWriter Output, string XsltPath, string ProgramDataFolder, bool ExportData, bool Repair)
Analyzes the database and exports findings to XML.
static string[] ToStringArray(this CaseInsensitiveString[] A)
Converts a case insensitive string array to a normal string array.
static async Task Update(object Object)
Updates an object in the database.
static Task< GenericObject > Generalize(object Object)
Creates a generalized representation of an object.
static Task< bool > Process(PredicateAsync< object > Processor, string Collection, int Offset, int MaxCount, params string[] SortOrder)
Processes objects in a given collection.
static Task< IPersistedQueue > GetQueue(string QueueName, bool CanBeNull)
Gets a persistent dictionary containing objects in a collection.
static Task< string > GetCollection(Type Type)
Gets the collection corresponding to a given type.
static async Task Delete(object Object)
Deletes an object in the database.
static async Task< T > LoadObject< T >(object ObjectId)
Loads an object given its Object ID ObjectId and its base type T .
static async Task< object > LoadObject(string CollectionName, object ObjectId)
Loads an object given its Object ID ObjectId and its collection name CollectionName .
static Task< bool > Process(PredicateAsync< object > Processor, string Collection, int Offset, int MaxCount, Filter Filter, params string[] SortOrder)
Processes objects in a given collection.
static Task< string[]> GetQueues()
Gets an array of available queue names.
static Task< bool > Process(Predicate< object > Processor, string Collection, params string[] SortOrder)
Processes objects in a given collection.
static Task< string[]> GetLabels(string Collection)
Gets an array of available labels for a collection.
static async Task Insert(params object[] Objects)
Inserts a set of objects into the default collection of the database.
static Task< bool > Process(Predicate< object > Processor, string Collection, int Offset, int MaxCount, Filter Filter, params string[] SortOrder)
Processes objects in a given collection.
static string[] GetFlaggedCollectionNames()
Gets the names of the collections that have been flagged as possibly corrupt.
static Task< string[][]> GetIndices(string CollectionName)
Removes an index from a collection, if one exist.
static async Task< PaginatedEnumerator< object > > Enumerate(string Collection, int PageSize, Filter Filter, params string[] SortOrder)
Finds the first page of objects in a given collection.
static Task< object > Specialize(GenericObject Object)
Creates a specialized representation of a generic object.
static async Task DeleteLazy(params object[] Objects)
Deletes a collection of objects in the database, if unlocked. If locked, objects will be deleted at n...
static async Task< IEnumerable< object > > FindDelete(string Collection, int Offset, int MaxCount, Filter Filter, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static async Task< string[]> Repair(XmlWriter Output, string XsltPath, string ProgramDataFolder, bool ExportData, ProfilerThread Thread)
Analyzes the database and repairs it if necessary. Results are exported to XML.
static Task< IEnumerable< object > > Find(string Collection, params string[] SortOrder)
Finds objects in a given collection.
static Task< IEnumerable< object > > FindDelete(string Collection, Filter Filter, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static Task< bool > Process(Predicate< object > Processor, string Collection, int Offset, int MaxCount, params string[] SortOrder)
Processes objects in a given collection.
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
static async Task UpdateLazy(params object[] Objects)
Updates a collection of objects in the database, if unlocked. If locked, objects will be updated at n...
static Task< object > TryLoadObject(string CollectionName, object ObjectId)
Tries to load an object given its Object ID ObjectId and its collection name CollectionName .
static async Task< T > FindFirstDeleteRest< T >(params string[] SortOrder)
Finds the first object of a given class T and deletes the rest.
static async Task InsertLazy(params object[] Objects)
Inserts an object into the database, if unlocked. If locked, object will be inserted at next opportun...
static async Task Insert(IEnumerable< object > Objects)
Inserts a set of objects into the default collection of the database.
static void Register(IDatabaseProvider DatabaseProvider, bool Lock)
Registers a database provider for use from the static Database class, throughout the lifetime of the ...
static async Task DeleteLazy(IEnumerable< object > Objects)
Deletes a collection of objects in the database, if unlocked. If locked, objects will be deleted at n...
static Task DropCollection(string CollectionName)
Drops a collection, if it exist.
static Task< IPage< object > > FindFirst(string Collection, int PageSize, Filter Filter, params string[] SortOrder)
Finds the first page of objects in a given collection.
static async Task Delete(params object[] Objects)
Deletes a collection of objects in the database.
static Task< IPage< T > > FindFirst< T >(int PageSize, params string[] SortOrder)
Finds the first page of objects of a given class T .
static async Task< PaginatedEnumerator< object > > Enumerate(string Collection, int PageSize, params string[] SortOrder)
Finds the first page of objects in a given collection.
static Task< IPersistedQueue > GetQueue(string QueueName)
Gets a persistent dictionary containing objects in a collection.
static async Task InsertLazy(IEnumerable< object > Objects)
Inserts an object into the database, if unlocked. If locked, object will be inserted at next opportun...
static async Task Clear(string CollectionName)
Clears a collection of all objects.
Database inconsistency exception. Raised when an inconsistency in the database has been found.
Base class for all filter classes.
Source of code flagging a collection for repair.
int Count
Number of times the collection has been flagged from this source.
Event arguments for database object events.
Paginated object enumerator.
Processor that uses an asynchronous predicate callback to process objects.
Processor that uses a predicate callback to process objects.
Generic object. Contains a sequence of properties.
Class that keeps track of events and timing for one thread.
Interface for database providers that can be plugged into the static Database class.
Task Update(object Object)
Updates an object in the database.
Task InsertLazy(object Object, ObjectCallback Callback)
Inserts an object into the database, if unlocked. If locked, object will be inserted at next opportun...
Task< string[]> Repair(XmlWriter Output, string XsltPath, string ProgramDataFolder, bool ExportData)
Analyzes the database and repairs it if necessary. Results are exported to XML.
Task< object > TryLoadObject(string CollectionName, object ObjectId)
Tries to load an object given its Object ID ObjectId and its collection name CollectionName .
Task< IPage< object > > FindFirst(string Collection, int PageSize, params string[] SortOrder)
Finds the first page of objects in a given collection.
Task< object > TryGetObjectId(object Object)
Tries to get the Object ID of an object, if it exists.
Task AddIndex(string CollectionName, string[] FieldNames)
Adds an index to a collection, if one does not already exist.
Task Delete(object Object)
Deletes an object in the database.
Task< object > Specialize(GenericObject Object)
Creates a specialized representation of a generic object.
Task< IEnumerable< object > > Find(string Collection, int Offset, int MaxCount, params string[] SortOrder)
Finds objects in a given collection.
Task< bool > IsLabel(string Collection, string Label)
Checks if a string is a label in a given collection.
Task< string[]> GetLabels(string Collection)
Gets an array of available labels for a collection.
Task< string > GetCollection(Type Type)
Gets the collection corresponding to a given type.
Task< bool > Export(IDatabaseExport Output, string[] CollectionNames)
Performs an export of the database.
Task< string[]> GetCollections()
Gets an array of available collections.
Task Clear(string CollectionName)
Clears a collection of all objects.
Task< string[]> GetDictionaries()
Gets an array of available dictionary collections.
Task< IPersistedQueue > GetQueue(string QueueName, bool CanBeNull)
Gets a persistent dictionary containing objects in a collection.
Task EndBulk()
Ends bulk-processing of data. Must be called once for every call to StartBulk.
Task UpdateLazy(object Object, ObjectCallback Callback)
Updates an object in the database, if unlocked. If locked, object will be updated at next opportunity...
Task< GenericObject > Generalize(object Object)
Creates a generalized representation of an object.
Task< string[][]> GetIndices(string CollectionName)
Removes an index from a collection, if one exist.
Task Insert(object Object)
Inserts an object into the database.
Task DeleteLazy(object Object, ObjectCallback Callback)
Deletes an object in the database, if unlocked. If locked, object will be deleted at next opportunity...
Task< IPersistentDictionary > GetDictionary(string Collection)
Gets a persistent dictionary containing objects in a collection.
Task< string[]> GetQueues()
Gets an array of available queue names.
Task< bool > Process(IProcessor< object > Processor, string Collection, int Offset, int MaxCount, params string[] SortOrder)
Processes untyped objects.
Task< string[]> Analyze(XmlWriter Output, string XsltPath, string ProgramDataFolder, bool ExportData)
Analyzes the database and exports findings to XML.
string[] GetExcludedCollections()
Gets an array of collections that should be excluded from backups.
Task< IEnumerable< object > > FindDelete(string Collection, int Offset, int MaxCount, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
Task DropCollection(string CollectionName)
Drops a collection, if it exist.
Task RemoveIndex(string CollectionName, string[] FieldNames)
Removes an index from a collection, if one exist.
Task< IPage< object > > FindNext(IPage< object > Page)
Finds the next page of objects in a given collection.
Task StartBulk()
Starts bulk-proccessing of data. Must be followed by a call to EndBulk.
Interface for paginated results.
Interface for processors of objects.
Interface for database exports.
Interface for iterations of database contents.