using System; namespace Firebase.Database.Query { /// /// Firebase query which references the child of current node. /// public class ChildQuery : FirebaseQuery { private readonly Func pathFactory; /// /// Initializes a new instance of the class. /// /// The parent. /// The path to the child node. /// The owner. public ChildQuery(FirebaseQuery parent, Func pathFactory, FirebaseClient client) : base(parent, client) { this.pathFactory = pathFactory; } /// /// Initializes a new instance of the class. /// /// The client. /// The path to the child node. public ChildQuery(FirebaseClient client, Func pathFactory) : this(null, pathFactory, client) { } /// /// Build the url segment of this child. /// /// The child of this child. /// The . protected override string BuildUrlSegment(FirebaseQuery child) { var s = pathFactory(); if (s != string.Empty && !s.EndsWith("/")) s += '/'; if (!(child is ChildQuery)) return s + ".json"; return s; } } }