コード例 #1
0
 private void AddSearchItem(FilterGroup model, string key, string val)
 {
     string field = "", orGroup = "", method = "";
     var regmethod = Regex.Match(key, @"(?<=\[).*(?=])");
     method = regmethod.Success ? regmethod.Value : "";
     var regorGroup = Regex.Match(key, @"(?<={).*(?=})");
     orGroup = regorGroup.Success ? regorGroup.Value : "AND";
     var regfield = Regex.Matches(key, @"(\[.*(}|]))(?<field>.*)");
     field = regfield.Count > 0 ? regfield[0].Groups["field"].Value : "";
     if (string.IsNullOrEmpty(method) || string.IsNullOrEmpty(field)) return;
     object value = val.Trim();
     var item = new FilterRule
     {
         Field = field,
         Data = value,
         Op =method
     };
     model.GroupOp = EnumHelper.GetInstance<GropuOp>(orGroup);
     model.Rules.Add(item);
 }