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); } }