From de0f076ef9ff546c9a90513259ad6c42cd2224b3 Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Sat, 29 Sep 2018 16:51:26 +0200 Subject: added firebase api --- FireBase/Query/ParameterQuery.cs | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 FireBase/Query/ParameterQuery.cs (limited to 'FireBase/Query/ParameterQuery.cs') diff --git a/FireBase/Query/ParameterQuery.cs b/FireBase/Query/ParameterQuery.cs new file mode 100644 index 0000000..e3d9717 --- /dev/null +++ b/FireBase/Query/ParameterQuery.cs @@ -0,0 +1,43 @@ +namespace Firebase.Database.Query +{ + using System; + + /// + /// 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; + this.separator = (this.Parent is ChildQuery) ? "?" : "&"; + } + + /// + /// Build the url segment represented by this query. + /// + /// The child. + /// The . + protected override string BuildUrlSegment(FirebaseQuery child) + { + return $"{this.separator}{this.parameterFactory()}={this.BuildUrlParameter(child)}"; + } + + /// + /// The build url parameter. + /// + /// The child. + /// The . + protected abstract string BuildUrlParameter(FirebaseQuery child); + } +} -- cgit v1.2.3-70-g09d2