123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System.Collections.Generic;
-
- namespace Luticate2.Utils.Dbo.Filter
- {
- public class LuFilterDbo
- {
- public string Query { get; set; }
-
- public IDictionary<string, string> Filters { get; set; }
-
- public string GetFilterString(string key, string defaultValue)
- {
- if (!Filters.ContainsKey(key))
- {
- return defaultValue;
- }
- return Filters[key];
- }
-
- public bool? GetFilterBool(string key, bool? defaultValue)
- {
- var value = GetFilterString(key, "").ToLower();
- if (value == "true")
- {
- return true;
- }
- if (value == "false")
- {
- return false;
- }
- return defaultValue;
- }
-
- public int? GetFilterInt(string key, int? defaultValue)
- {
- int v;
- if (int.TryParse(GetFilterString(key, ""), out v))
- {
- return v;
- }
- return defaultValue;
- }
-
- public double? GetFilterFloat(string key, double? defaultValue)
- {
- double v;
- if (double.TryParse(GetFilterString(key, ""), out v))
- {
- return v;
- }
- return defaultValue;
- }
- }
- }
|