diff options
Diffstat (limited to 'FireBase/Offline/DatabaseExtensions.cs')
-rw-r--r-- | FireBase/Offline/DatabaseExtensions.cs | 111 |
1 files changed, 74 insertions, 37 deletions
diff --git a/FireBase/Offline/DatabaseExtensions.cs b/FireBase/Offline/DatabaseExtensions.cs index 56dcf46..e7c4074 100644 --- a/FireBase/Offline/DatabaseExtensions.cs +++ b/FireBase/Offline/DatabaseExtensions.cs @@ -1,24 +1,26 @@ -namespace Firebase.Database.Offline -{ - using System; - using System.Collections; - using System.Collections.Generic; - using System.Linq.Expressions; - using System.Reflection; - using Query; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Reflection; +using Firebase.Database.Query; +namespace Firebase.Database.Offline +{ public static class DatabaseExtensions { /// <summary> - /// Create new instances of the <see cref="RealtimeDatabase{T}"/>. + /// Create new instances of the <see cref="RealtimeDatabase{T}" />. /// </summary> /// <typeparam name="T"> Type of elements. </typeparam> /// <param name="filenameModifier"> Custom string which will get appended to the file name. </param> /// <param name="elementRoot"> Optional custom root element of received json items. </param> - /// <param name="streamingOptions"> Realtime streaming options. </param> + /// <param name="streamingOptions"> Realtime streaming options. </param> /// <param name="initialPullStrategy"> Specifies what strategy should be used for initial pulling of server data. </param> - /// <param name="pushChanges"> Specifies whether changed items should actually be pushed to the server. It this is false, then Put / Post / Delete will not affect server data. </param> - /// <returns> The <see cref="RealtimeDatabase{T}"/>. </returns> + /// <param name="pushChanges"> + /// Specifies whether changed items should actually be pushed to the server. It this is false, + /// then Put / Post / Delete will not affect server data. + /// </param> + /// <returns> The <see cref="RealtimeDatabase{T}" />. </returns> public static RealtimeDatabase<T> AsRealtimeDatabase<T>(this ChildQuery query, string filenameModifier = "", string elementRoot = "", StreamingOptions streamingOptions = StreamingOptions.LatestOnly, InitialPullStrategy initialPullStrategy = InitialPullStrategy.MissingOnly, bool pushChanges = true) @@ -29,16 +31,19 @@ } /// <summary> - /// Create new instances of the <see cref="RealtimeDatabase{T}"/>. + /// Create new instances of the <see cref="RealtimeDatabase{T}" />. /// </summary> /// <typeparam name="T"> Type of elements. </typeparam> - /// <typeparam name="TSetHandler"> Type of the custom <see cref="ISetHandler{T}"/> to use. </typeparam> + /// <typeparam name="TSetHandler"> Type of the custom <see cref="ISetHandler{T}" /> to use. </typeparam> /// <param name="filenameModifier"> Custom string which will get appended to the file name. </param> /// <param name="elementRoot"> Optional custom root element of received json items. </param> - /// <param name="streamingOptions"> Realtime streaming options. </param> + /// <param name="streamingOptions"> Realtime streaming options. </param> /// <param name="initialPullStrategy"> Specifies what strategy should be used for initial pulling of server data. </param> - /// <param name="pushChanges"> Specifies whether changed items should actually be pushed to the server. It this is false, then Put / Post / Delete will not affect server data. </param> - /// <returns> The <see cref="RealtimeDatabase{T}"/>. </returns> + /// <param name="pushChanges"> + /// Specifies whether changed items should actually be pushed to the server. It this is false, + /// then Put / Post / Delete will not affect server data. + /// </param> + /// <returns> The <see cref="RealtimeDatabase{T}" />. </returns> public static RealtimeDatabase<T> AsRealtimeDatabase<T, TSetHandler>(this ChildQuery query, string filenameModifier = "", string elementRoot = "", StreamingOptions streamingOptions = StreamingOptions.LatestOnly, @@ -52,12 +57,15 @@ } /// <summary> - /// Overwrites existing object with given key leaving any missing properties intact in firebase. + /// Overwrites existing object with given key leaving any missing properties intact in firebase. /// </summary> /// <param name="key"> The key. </param> /// <param name="obj"> The object to set. </param> /// <param name="syncOnline"> Indicates whether the item should be synced online. </param> - /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param> + /// <param name="priority"> + /// The priority. Objects with higher priority will be synced first. Higher number indicates higher + /// priority. + /// </param> public static void Patch<T>(this RealtimeDatabase<T> db, string key, T obj, bool syncOnline = true, int priority = 1) where T : class @@ -66,12 +74,15 @@ } /// <summary> - /// Overwrites existing object with given key. + /// Overwrites existing object with given key. /// </summary> /// <param name="key"> The key. </param> /// <param name="obj"> The object to set. </param> /// <param name="syncOnline"> Indicates whether the item should be synced online. </param> - /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param> + /// <param name="priority"> + /// The priority. Objects with higher priority will be synced first. Higher number indicates higher + /// priority. + /// </param> public static void Put<T>(this RealtimeDatabase<T> db, string key, T obj, bool syncOnline = true, int priority = 1) where T : class @@ -80,11 +91,14 @@ } /// <summary> - /// Adds a new entity to the Database. + /// Adds a new entity to the Database. /// </summary> /// <param name="obj"> The object to add. </param> /// <param name="syncOnline"> Indicates whether the item should be synced online. </param> - /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param> + /// <param name="priority"> + /// The priority. Objects with higher priority will be synced first. Higher number indicates higher + /// priority. + /// </param> /// <returns> The generated key for this object. </returns> public static string Post<T>(this RealtimeDatabase<T> db, T obj, bool syncOnline = true, int priority = 1) where T : class @@ -97,11 +111,14 @@ } /// <summary> - /// Deletes the entity with the given key. + /// Deletes the entity with the given key. /// </summary> /// <param name="key"> The key. </param> /// <param name="syncOnline"> Indicates whether the item should be synced online. </param> - /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param> + /// <param name="priority"> + /// The priority. Objects with higher priority will be synced first. Higher number indicates higher + /// priority. + /// </param> public static void Delete<T>(this RealtimeDatabase<T> db, string key, bool syncOnline = true, int priority = 1) where T : class { @@ -109,7 +126,8 @@ } /// <summary> - /// Do a Put for a nested property specified by <paramref name="propertyExpression"/> of an object with key <paramref name="key"/>. + /// Do a Put for a nested property specified by <paramref name="propertyExpression" /> of an object with key + /// <paramref name="key" />. /// </summary> /// <typeparam name="T"> Type of the root elements. </typeparam> /// <typeparam name="TProperty"> Type of the property being modified</typeparam> @@ -118,7 +136,10 @@ /// <param name="propertyExpression"> Expression on the root element leading to target value to modify. </param> /// <param name="value"> Value to put. </param> /// <param name="syncOnline"> Indicates whether the item should be synced online. </param> - /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param> + /// <param name="priority"> + /// The priority. Objects with higher priority will be synced first. Higher number indicates higher + /// priority. + /// </param> public static void Put<T, TProperty>(this RealtimeDatabase<T> db, string key, Expression<Func<T, TProperty>> propertyExpression, TProperty value, bool syncOnline = true, int priority = 1) @@ -128,7 +149,8 @@ } /// <summary> - /// Do a Patch for a nested property specified by <paramref name="propertyExpression"/> of an object with key <paramref name="key"/>. + /// Do a Patch for a nested property specified by <paramref name="propertyExpression" /> of an object with key + /// <paramref name="key" />. /// </summary> /// <typeparam name="T"> Type of the root elements. </typeparam> /// <typeparam name="TProperty"> Type of the property being modified</typeparam> @@ -137,7 +159,10 @@ /// <param name="propertyExpression"> Expression on the root element leading to target value to modify. </param> /// <param name="value"> Value to patch. </param> /// <param name="syncOnline"> Indicates whether the item should be synced online. </param> - /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param> + /// <param name="priority"> + /// The priority. Objects with higher priority will be synced first. Higher number indicates higher + /// priority. + /// </param> public static void Patch<T, TProperty>(this RealtimeDatabase<T> db, string key, Expression<Func<T, TProperty>> propertyExpression, TProperty value, bool syncOnline = true, int priority = 1) @@ -147,7 +172,8 @@ } /// <summary> - /// Delete a nested property specified by <paramref name="propertyExpression"/> of an object with key <paramref name="key"/>. This basically does a Put with null value. + /// Delete a nested property specified by <paramref name="propertyExpression" /> of an object with key + /// <paramref name="key" />. This basically does a Put with null value. /// </summary> /// <typeparam name="T"> Type of the root elements. </typeparam> /// <typeparam name="TProperty"> Type of the property being modified</typeparam> @@ -156,7 +182,10 @@ /// <param name="propertyExpression"> Expression on the root element leading to target value to modify. </param> /// <param name="value"> Value to put. </param> /// <param name="syncOnline"> Indicates whether the item should be synced online. </param> - /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param> + /// <param name="priority"> + /// The priority. Objects with higher priority will be synced first. Higher number indicates higher + /// priority. + /// </param> public static void Delete<T, TProperty>(this RealtimeDatabase<T> db, string key, Expression<Func<T, TProperty>> propertyExpression, bool syncOnline = true, int priority = 1) where T : class @@ -166,8 +195,9 @@ } /// <summary> - /// Post a new entity into the nested dictionary specified by <paramref name="propertyExpression"/> of an object with key <paramref name="key"/>. - /// The key of the new entity is automatically generated. + /// Post a new entity into the nested dictionary specified by <paramref name="propertyExpression" /> of an object with + /// key <paramref name="key" />. + /// The key of the new entity is automatically generated. /// </summary> /// <typeparam name="T"> Type of the root elements. </typeparam> /// <typeparam name="TSelector"> Type of the dictionary being modified</typeparam> @@ -177,7 +207,10 @@ /// <param name="propertyExpression"> Expression on the root element leading to target value to modify. </param> /// <param name="value"> Value to put. </param> /// <param name="syncOnline"> Indicates whether the item should be synced online. </param> - /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param> + /// <param name="priority"> + /// The priority. Objects with higher priority will be synced first. Higher number indicates higher + /// priority. + /// </param> public static void Post<T, TSelector, TProperty>(this RealtimeDatabase<T> db, string key, Expression<Func<T, TSelector>> propertyExpression, TProperty value, bool syncOnline = true, int priority = 1) @@ -193,8 +226,9 @@ } /// <summary> - /// Delete an entity with key <paramref name="dictionaryKey"/> in the nested dictionary specified by <paramref name="propertyExpression"/> of an object with key <paramref name="key"/>. - /// The key of the new entity is automatically generated. + /// Delete an entity with key <paramref name="dictionaryKey" /> in the nested dictionary specified by + /// <paramref name="propertyExpression" /> of an object with key <paramref name="key" />. + /// The key of the new entity is automatically generated. /// </summary> /// <typeparam name="T"> Type of the root elements. </typeparam> /// <typeparam name="TSelector"> Type of the dictionary being modified</typeparam> @@ -204,7 +238,10 @@ /// <param name="propertyExpression"> Expression on the root element leading to target value to modify. </param> /// <param name="dictionaryKey"> Key within the nested dictionary to delete. </param> /// <param name="syncOnline"> Indicates whether the item should be synced online. </param> - /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param> + /// <param name="priority"> + /// The priority. Objects with higher priority will be synced first. Higher number indicates higher + /// priority. + /// </param> public static void Delete<T, TProperty>(this RealtimeDatabase<T> db, string key, Expression<Func<T, IDictionary<string, TProperty>>> propertyExpression, string dictionaryKey, bool syncOnline = true, int priority = 1) |