From 4368a849fb14caa9687eb212860fe339f1d3a9ab Mon Sep 17 00:00:00 2001 From: Constantin Nickel Date: Tue, 15 Mar 2022 10:46:20 +0100 Subject: [PATCH] Add a static method for creating custom filters ``` using Modio.Filters; var filter = Filter.Custom("name", Operator.Equals, "foobar"); ``` --- Modio/Filters/Filter.cs | 48 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/Modio/Filters/Filter.cs b/Modio/Filters/Filter.cs index 86d43a8..b5ac2f2 100644 --- a/Modio/Filters/Filter.cs +++ b/Modio/Filters/Filter.cs @@ -26,6 +26,14 @@ internal Filter(string name, string value) : this() parameters[name] = value; } + /// + /// Initializes a new custom instance of . + /// + public static Filter Custom(string name, Operator op, string value) + { + return new Filter(op.ToName(name), value); + } + /// /// Initializes a new instance of with . /// @@ -450,18 +458,56 @@ public Filter NotIn(params T[] values) } } - internal enum Operator + /// + /// Filter operators of mod.io + /// + /// + /// https://docs.mod.io/#filtering + public enum Operator { + /// + /// Equal to (`id=1`) + /// Equal, + /// + /// Equal to (`id-not=1`) + /// NotEqual, + /// + /// Equivalent to SQL's `LIKE`. `*` is equivalent to SQL's `%`. (`name-lk=foo*`) + /// Like, + /// + /// Equivalent to SQL's `NOT LIKE` (`name-not-lk=foo*`) + /// NotLike, + /// + /// Equivalent to SQL's `IN` (`id-in=1,3,5`) + /// In, + /// + /// Equivalent to SQL's `NOT IN` (`id-not-in=1,3,5`) + /// NotIn, + /// + /// Less than (`id-st=10`) + /// LessThan, + /// + /// Less than or equal to (`id-max=10`) + /// LessOrEqual, + /// + /// Greater than (`id-gt=5`) + /// GreaterThan, + /// + /// Greater than or equal to (`id-min=5`) + /// GreaterOrEqual, + /// + /// Match bits (`maturity_option-bitwise-and=5`) + /// BitwiseAnd, }