From e6181c24124d97f2fbc932b8a68311e625463156 Mon Sep 17 00:00:00 2001 From: uzvkl Date: Tue, 11 Jun 2019 23:05:52 +0200 Subject: Move dsa related stuff to subfolder --- dsa/FireBase/Query/QueryFactoryExtensions.cs | 187 +++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 dsa/FireBase/Query/QueryFactoryExtensions.cs (limited to 'dsa/FireBase/Query/QueryFactoryExtensions.cs') diff --git a/dsa/FireBase/Query/QueryFactoryExtensions.cs b/dsa/FireBase/Query/QueryFactoryExtensions.cs new file mode 100644 index 0000000..71dae5c --- /dev/null +++ b/dsa/FireBase/Query/QueryFactoryExtensions.cs @@ -0,0 +1,187 @@ +using System; + +namespace Firebase.Database.Query +{ + /// + /// Query extensions providing linq like syntax for firebase server methods. + /// + public static class QueryFactoryExtensions + { + /// + /// Adds an auth parameter to the query. + /// + /// The child. + /// The auth token. + /// The . + internal static AuthQuery WithAuth(this FirebaseQuery node, Func tokenFactory) + { + return new AuthQuery(node, tokenFactory, node.Client); + } + + /// + /// References a sub child of the existing node. + /// + /// The child. + /// The path of sub child. + /// The . + public static ChildQuery Child(this ChildQuery node, Func pathFactory) + { + return new ChildQuery(node, pathFactory, node.Client); + } + + /// + /// Order data by given . Note that this is used mainly for following filtering + /// queries and due to firebase implementation + /// the data may actually not be ordered. + /// + /// The child. + /// The property name. + /// The . + public static OrderQuery OrderBy(this ChildQuery child, Func propertyNameFactory) + { + return new OrderQuery(child, propertyNameFactory, child.Client); + } + + /// + /// Order data by $key. Note that this is used mainly for following filtering queries and due to firebase + /// implementation + /// the data may actually not be ordered. + /// + /// The child. + /// The . + public static OrderQuery OrderByKey(this ChildQuery child) + { + return child.OrderBy("$key"); + } + + /// + /// Order data by $value. Note that this is used mainly for following filtering queries and due to firebase + /// implementation + /// the data may actually not be ordered. + /// + /// The child. + /// The . + public static OrderQuery OrderByValue(this ChildQuery child) + { + return child.OrderBy("$value"); + } + + /// + /// Order data by $priority. Note that this is used mainly for following filtering queries and due to firebase + /// implementation + /// the data may actually not be ordered. + /// + /// The child. + /// The . + public static OrderQuery OrderByPriority(this ChildQuery child) + { + return child.OrderBy("$priority"); + } + + /// + /// Instructs firebase to send data greater or equal to the . This must be preceded by an + /// OrderBy query. + /// + /// Current node. + /// Value to start at. + /// The . + public static FilterQuery StartAt(this ParameterQuery child, Func valueFactory) + { + return new FilterQuery(child, () => "startAt", valueFactory, child.Client); + } + + /// + /// Instructs firebase to send data lower or equal to the . This must be preceded by an + /// OrderBy query. + /// + /// Current node. + /// Value to start at. + /// The . + public static FilterQuery EndAt(this ParameterQuery child, Func valueFactory) + { + return new FilterQuery(child, () => "endAt", valueFactory, child.Client); + } + + /// + /// Instructs firebase to send data equal to the . This must be preceded by an OrderBy + /// query. + /// + /// Current node. + /// Value to start at. + /// The . + public static FilterQuery EqualTo(this ParameterQuery child, Func valueFactory) + { + return new FilterQuery(child, () => "equalTo", valueFactory, child.Client); + } + + /// + /// Instructs firebase to send data greater or equal to the . This must be preceded by an + /// OrderBy query. + /// + /// Current node. + /// Value to start at. + /// The . + public static FilterQuery StartAt(this ParameterQuery child, Func valueFactory) + { + return new FilterQuery(child, () => "startAt", valueFactory, child.Client); + } + + /// + /// Instructs firebase to send data lower or equal to the . This must be preceded by an + /// OrderBy query. + /// + /// Current node. + /// Value to start at. + /// The . + public static FilterQuery EndAt(this ParameterQuery child, Func valueFactory) + { + return new FilterQuery(child, () => "endAt", valueFactory, child.Client); + } + + /// + /// Instructs firebase to send data equal to the . This must be preceded by an OrderBy + /// query. + /// + /// Current node. + /// Value to start at. + /// The . + public static FilterQuery EqualTo(this ParameterQuery child, Func valueFactory) + { + return new FilterQuery(child, () => "equalTo", valueFactory, child.Client); + } + + /// + /// Instructs firebase to send data equal to the . This must be preceded by an OrderBy + /// query. + /// + /// Current node. + /// Value to start at. + /// The . + public static FilterQuery EqualTo(this ParameterQuery child, Func valueFactory) + { + return new FilterQuery(child, () => "equalTo", valueFactory, child.Client); + } + + /// + /// Limits the result to first items. + /// + /// Current node. + /// Number of elements. + /// The . + public static FilterQuery LimitToFirst(this ParameterQuery child, Func countFactory) + { + return new FilterQuery(child, () => "limitToFirst", () => countFactory(), child.Client); + } + + /// + /// Limits the result to last items. + /// + /// Current node. + /// Number of elements. + /// The . + public static FilterQuery LimitToLast(this ParameterQuery child, Func countFactory) + { + return new FilterQuery(child, () => "limitToLast", () => countFactory(), child.Client); + } + } +} \ No newline at end of file -- cgit v1.2.3-70-g09d2