summaryrefslogtreecommitdiff
path: root/FireBase/Query/OrderQuery.cs
blob: 302d1a3d2eba7985b48cd4ad041f3817675dc6f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;

namespace Firebase.Database.Query
{
    /// <summary>
    ///     Represents a firebase ordering query, e.g. "?OrderBy=Foo".
    /// </summary>
    public class OrderQuery : ParameterQuery
    {
        private readonly Func<string> propertyNameFactory;

        /// <summary>
        ///     Initializes a new instance of the <see cref="OrderQuery" /> class.
        /// </summary>
        /// <param name="parent"> The query parent. </param>
        /// <param name="propertyNameFactory"> The property name. </param>
        /// <param name="client"> The owning client. </param>
        public OrderQuery(ChildQuery parent, Func<string> propertyNameFactory, FirebaseClient client)
            : base(parent, () => "orderBy", client)
        {
            this.propertyNameFactory = propertyNameFactory;
        }

        /// <summary>
        ///     The build url parameter.
        /// </summary>
        /// <param name="child"> The child. </param>
        /// <returns> The <see cref="string" />. </returns>
        protected override string BuildUrlParameter(FirebaseQuery child)
        {
            return $"\"{propertyNameFactory()}\"";
        }
    }
}