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