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/ChildQuery.cs | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 dsa/FireBase/Query/ChildQuery.cs (limited to 'dsa/FireBase/Query/ChildQuery.cs') diff --git a/dsa/FireBase/Query/ChildQuery.cs b/dsa/FireBase/Query/ChildQuery.cs new file mode 100644 index 0000000..014fe09 --- /dev/null +++ b/dsa/FireBase/Query/ChildQuery.cs @@ -0,0 +1,50 @@ +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; + } + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf