Przeglądaj źródła

rename NotContains to NotContain

Lith 9 miesięcy temu
rodzic
commit
b9db05579b

+ 2 - 2
README.md

@@ -27,7 +27,7 @@ FilterRule can express logical combinations (And / Or / Not) and basic logical e
   - Logical Judgement
     - [object] is null (==null) / is not null (!=null)
     - [numeric] compare: ==  !=  >  >=  <  <=
-    - [string] compare: Contains NotContains StartsWith EndsWith IsNullOrEmpty IsNotNullOrEmpty
+    - [string] compare: Contains NotContain StartsWith EndsWith IsNullOrEmpty IsNotNullOrEmpty
     - [array] contains: In / NotIn
     - custom operator
 
@@ -71,7 +71,7 @@ namespace App
 > FilterRule is JSON-formatted data where the condition can be `and`, `or`, `not`, `notand`, or `notor` (a combination of `not` and `or`).   
 > `rules` can be nested FilterRules.   
 > `field` can be a nested property, such as `id` or `job.name`.   
-> `operator` can be one of the following: `IsNull`, `IsNotNull`, `In`, `NotIn`, `=`, `!=`, `>`, `>=`, `<`, `<=`, `Contains`, `NotContains`, `StartsWith`, `EndsWith`, `IsNullOrEmpty`, `IsNotNullOrEmpty`, etc.    
+> `operator` can be one of the following: `IsNull`, `IsNotNull`, `In`, `NotIn`, `=`, `!=`, `>`, `>=`, `<`, `<=`, `Contains`, `NotContain`, `StartsWith`, `EndsWith`, `IsNullOrEmpty`, `IsNotNullOrEmpty`, etc.    
 ``` json
 {
   "condition": "and",

+ 2 - 2
doc/README_CN.md

@@ -26,7 +26,7 @@ FilerRule 可以表达 逻辑组合 (And / Or / Not ) 和 基本的逻辑判
   - Logical Judgement
     - [object] is null (==null) / is not null (!=null)
     - [numeric] compare: ==  !=  >  >=  <  <=
-    - [string] compare: Contains NotContains StartsWith EndsWith IsNullOrEmpty IsNotNullOrEmpty
+    - [string] compare: Contains NotContain StartsWith EndsWith IsNullOrEmpty IsNotNullOrEmpty
     - [array] contains: In / NotIn
     - custom operator
 
@@ -68,7 +68,7 @@ namespace App
 > FilterRule 为json格式的数据,其中 condition 可以为 `and`, `or`, `not`, `notand`, `notor`(not or 的组合)    
 > `rules` 可以为嵌套的 FilterRule。    
 > `field` 可以为嵌套属性, 例如 `id` , `job.name` .    
-> `operator` 可以为 `IsNull`, `IsNotNull`, `In`, `NotIn`, `=`, `!=`, `>`, `>=`, `<`, `<=`, `Contains`, `NotContains`, `StartsWith`, `EndsWith`, `IsNullOrEmpty`, `IsNotNullOrEmpty` 等    
+> `operator` 可以为 `IsNull`, `IsNotNull`, `In`, `NotIn`, `=`, `!=`, `>`, `>=`, `<`, `<=`, `Contains`, `NotContain`, `StartsWith`, `EndsWith`, `IsNullOrEmpty`, `IsNotNullOrEmpty` 等    
 ``` json
 {
   "condition": "and",

+ 1 - 1
src/Vit.Linq/Filter/ComponentModel/IFilterRule.cs

@@ -24,7 +24,7 @@ namespace Vit.Linq.Filter.ComponentModel
         ///     "IsNull", "IsNotNull" ,
         ///     "=", "!=", "&gt;", "&lt;" , "&gt;=", "&lt;=", 
         ///     "In" , "NotIn" ,
-        ///     "Contains", "NotContains", "StartsWith", "EndsWith" , "IsNullOrEmpty", "IsNotNullOrEmpty"
+        ///     "Contains", "NotContain", "StartsWith", "EndsWith" , "IsNullOrEmpty", "IsNotNullOrEmpty"
         ///
         ///    //TODO [array]   "is empty", "is not empty"
         /// </summary>

+ 5 - 5
src/Vit.Linq/Filter/ComponentModel/RuleCondition.cs

@@ -2,11 +2,11 @@
 {
     public class RuleCondition
     {
-        public const string And = "And";
-        public const string Or = "Or";
+        public const string And = nameof(And);
+        public const string Or = nameof(Or);
 
-        public const string Not = "Not";
-        public const string NotAnd = "NotAnd";
-        public const string NotOr = "NotOr";
+        public const string Not = nameof(Not);
+        public const string NotAnd = nameof(NotAnd);
+        public const string NotOr = nameof(NotOr);
     }
 }

+ 10 - 10
src/Vit.Linq/Filter/ComponentModel/RuleOperator.cs

@@ -2,8 +2,8 @@
 {
     public class RuleOperator
     {
-        public const string IsNull = "IsNull";
-        public const string IsNotNull = "IsNotNull";
+        public const string IsNull = nameof(IsNull);
+        public const string IsNotNull = nameof(IsNotNull);
 
 
         public const string Equal = "=";
@@ -16,15 +16,15 @@
 
 
 
-        public const string In = "In";
-        public const string NotIn = "NotIn";
+        public const string In = nameof(In);
+        public const string NotIn = nameof(NotIn);
 
-        public const string Contains = "Contains";
-        public const string NotContains = "NotContains";
-        public const string StartsWith = "StartsWith";
-        public const string EndsWith = "EndsWith";
-        public const string IsNullOrEmpty = "IsNullOrEmpty";
-        public const string IsNotNullOrEmpty = "IsNotNullOrEmpty";
+        public const string Contains = nameof(Contains);
+        public const string NotContain = nameof(NotContain);
+        public const string StartsWith = nameof(StartsWith);
+        public const string EndsWith = nameof(EndsWith);
+        public const string IsNullOrEmpty = nameof(IsNullOrEmpty);
+        public const string IsNotNullOrEmpty = nameof(IsNotNullOrEmpty);
 
 
     }

+ 1 - 1
src/Vit.Linq/Filter/FilterConvertor/OperatorConvert/StringOperatorConvertor.cs

@@ -21,7 +21,7 @@ namespace Vit.Linq.Filter.FilterConvertor.OperatorConvert
 
                 return (true, Expression.AndAlso(Expression.Not(nullCheck), contains));
             }
-            else if (RuleOperator.NotContains.Equals(arg.Operator, arg.comparison))
+            else if (RuleOperator.NotContain.Equals(arg.Operator, arg.comparison))
             {
                 var leftValueExpression = arg.leftValueExpression;
                 var leftValueType = arg.leftValueType;

+ 4 - 4
test/Vit.Linq.MsTest/Filter/Filter_TestBase.cs

@@ -343,13 +343,13 @@ namespace Vit.Linq.MsTest.Filter
             }
             #endregion
 
-            #region ##2 NotContains
+            #region ##2 NotContain
             {
                 //###1
                 {
                     var query = GetQueryable();
 
-                    var strRule = "{'field':'name',  'operator': 'NotContains',  'value': '987' }".Replace("'", "\"");
+                    var strRule = "{'field':'name',  'operator': 'NotContain',  'value': '987' }".Replace("'", "\"");
                     var rule = GetRule(strRule);
                     var result = Filter(ToQuery(query), rule);
                     Assert.AreEqual(999, result.Count);
@@ -361,7 +361,7 @@ namespace Vit.Linq.MsTest.Filter
                     var query = GetQueryable();
                     query.Skip(987).FirstOrDefault().name = null;
 
-                    var strRule = "{'field':'name',  'operator': 'NotContains',  'value': '987' }".Replace("'", "\"");
+                    var strRule = "{'field':'name',  'operator': 'NotContain',  'value': '987' }".Replace("'", "\"");
                     var rule = GetRule(strRule);
                     var result = Filter(ToQuery(query), rule);
                     Assert.AreEqual(1000, result.Count);
@@ -372,7 +372,7 @@ namespace Vit.Linq.MsTest.Filter
                     var query = GetQueryable();
                     query.Skip(987).FirstOrDefault().name = "";
 
-                    var strRule = "{'field':'name',  'operator': 'NotContains',  'value': '987' }".Replace("'", "\"");
+                    var strRule = "{'field':'name',  'operator': 'NotContain',  'value': '987' }".Replace("'", "\"");
                     var rule = GetRule(strRule);
                     var result = Filter(ToQuery(query), rule);
                     Assert.AreEqual(1000, result.Count);