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/ParameterQuery.cs | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 dsa/FireBase/Query/ParameterQuery.cs (limited to 'dsa/FireBase/Query/ParameterQuery.cs') diff --git a/dsa/FireBase/Query/ParameterQuery.cs b/dsa/FireBase/Query/ParameterQuery.cs new file mode 100644 index 0000000..572224c --- /dev/null +++ b/dsa/FireBase/Query/ParameterQuery.cs @@ -0,0 +1,43 @@ +using System; + +namespace Firebase.Database.Query +{ + /// + /// Represents a parameter in firebase query, e.g. "?data=foo". + /// + public abstract class ParameterQuery : FirebaseQuery + { + private readonly Func parameterFactory; + private readonly string separator; + + /// + /// Initializes a new instance of the class. + /// + /// The parent of this query. + /// The parameter. + /// The owning client. + protected ParameterQuery(FirebaseQuery parent, Func parameterFactory, FirebaseClient client) + : base(parent, client) + { + this.parameterFactory = parameterFactory; + separator = Parent is ChildQuery ? "?" : "&"; + } + + /// + /// Build the url segment represented by this query. + /// + /// The child. + /// The . + protected override string BuildUrlSegment(FirebaseQuery child) + { + return $"{separator}{parameterFactory()}={BuildUrlParameter(child)}"; + } + + /// + /// The build url parameter. + /// + /// The child. + /// The . + protected abstract string BuildUrlParameter(FirebaseQuery child); + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf