diff options
author | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
---|---|---|
committer | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
commit | 1509b5ef3d7e9e71d9294e234ec0e39f2d831998 (patch) | |
tree | 78300ffff230958101b422a4e6026925b287822f /FireBase/Query/FilterQuery.cs | |
parent | c3bb858bb54dc8c64bbd48054c2c58dc0073f09c (diff) | |
parent | c4d046858e0822b7c2c540ac2368b2c0e88e7a26 (diff) |
Merge branch 'scribble' of https://github.com/TrueDoctor/DiscoBot into scribble
Diffstat (limited to 'FireBase/Query/FilterQuery.cs')
-rw-r--r-- | FireBase/Query/FilterQuery.cs | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/FireBase/Query/FilterQuery.cs b/FireBase/Query/FilterQuery.cs index f9f6271..3434d1d 100644 --- a/FireBase/Query/FilterQuery.cs +++ b/FireBase/Query/FilterQuery.cs @@ -1,81 +1,77 @@ -namespace Firebase.Database.Query -{ - using System; - using System.Globalization; +using System; +using System.Globalization; +namespace Firebase.Database.Query +{ /// <summary> - /// Represents a firebase filtering query, e.g. "?LimitToLast=10". + /// Represents a firebase filtering query, e.g. "?LimitToLast=10". /// </summary> - public class FilterQuery : ParameterQuery + public class FilterQuery : ParameterQuery { - private readonly Func<string> valueFactory; - private readonly Func<double> doubleValueFactory; private readonly Func<bool> boolValueFactory; + private readonly Func<double> doubleValueFactory; + private readonly Func<string> valueFactory; /// <summary> - /// Initializes a new instance of the <see cref="FilterQuery"/> class. + /// Initializes a new instance of the <see cref="FilterQuery" /> class. /// </summary> /// <param name="parent"> The parent. </param> /// <param name="filterFactory"> The filter. </param> /// <param name="valueFactory"> The value for filter. </param> - /// <param name="client"> The owning client. </param> - public FilterQuery(FirebaseQuery parent, Func<string> filterFactory, Func<string> valueFactory, FirebaseClient client) + /// <param name="client"> The owning client. </param> + public FilterQuery(FirebaseQuery parent, Func<string> filterFactory, Func<string> valueFactory, + FirebaseClient client) : base(parent, filterFactory, client) { this.valueFactory = valueFactory; } /// <summary> - /// Initializes a new instance of the <see cref="FilterQuery"/> class. + /// Initializes a new instance of the <see cref="FilterQuery" /> class. /// </summary> /// <param name="parent"> The parent. </param> /// <param name="filterFactory"> The filter. </param> /// <param name="valueFactory"> The value for filter. </param> /// <param name="client"> The owning client. </param> - public FilterQuery(FirebaseQuery parent, Func<string> filterFactory, Func<double> valueFactory, FirebaseClient client) + public FilterQuery(FirebaseQuery parent, Func<string> filterFactory, Func<double> valueFactory, + FirebaseClient client) : base(parent, filterFactory, client) { - this.doubleValueFactory = valueFactory; + doubleValueFactory = valueFactory; } /// <summary> - /// Initializes a new instance of the <see cref="FilterQuery"/> class. + /// Initializes a new instance of the <see cref="FilterQuery" /> class. /// </summary> /// <param name="parent"> The parent. </param> /// <param name="filterFactory"> The filter. </param> /// <param name="valueFactory"> The value for filter. </param> /// <param name="client"> The owning client. </param> - public FilterQuery(FirebaseQuery parent, Func<string> filterFactory, Func<bool> valueFactory, FirebaseClient client) + public FilterQuery(FirebaseQuery parent, Func<string> filterFactory, Func<bool> valueFactory, + FirebaseClient client) : base(parent, filterFactory, client) { - this.boolValueFactory = valueFactory; + boolValueFactory = valueFactory; } /// <summary> - /// The build url parameter. + /// The build url parameter. /// </summary> - /// <param name="child"> The child. </param> - /// <returns> Url parameter part of the resulting path. </returns> + /// <param name="child"> The child. </param> + /// <returns> Url parameter part of the resulting path. </returns> protected override string BuildUrlParameter(FirebaseQuery child) { - if (this.valueFactory != null) - { - if(this.valueFactory() == null) - { - return $"null"; - } - return $"\"{this.valueFactory()}\""; - } - else if (this.doubleValueFactory != null) + if (valueFactory != null) { - return this.doubleValueFactory().ToString(CultureInfo.InvariantCulture); - } - else if (this.boolValueFactory != null) - { - return $"{this.boolValueFactory().ToString().ToLower()}"; + if (valueFactory() == null) return "null"; + return $"\"{valueFactory()}\""; } + if (doubleValueFactory != null) + return doubleValueFactory().ToString(CultureInfo.InvariantCulture); + if (boolValueFactory != null) return $"{boolValueFactory().ToString().ToLower()}"; + return string.Empty; } } -} +}
\ No newline at end of file |