private static List <NotificationCompareResult> CongruentFilter(int[] indexArray, List <ConditionData> conditions) { List <NotificationCompareResult> _result = new List <NotificationCompareResult>(); for (int i = 0; i < indexArray.Length; i++) { bool _isMatch = true; for (int j = 0; j < conditions.Count; j++) { ConditionData _conditionUnit = conditions[j]; int _fieldCount = conditionClassColumns[_conditionUnit.GetType()].Count; string[] _paramField = new string[_fieldCount]; for (int k = 0; k < _fieldCount; k++) { int _columnIndex = conditionClassColumns[_conditionUnit.GetType()][k]; _paramField[k] = notificationUnitStorage[indexArray[i]][_columnIndex]; } _isMatch = PropertyCompare(_paramField, _conditionUnit); if (!_isMatch) { break; } } if (_isMatch) { NotificationCompareResult _compareResult = new NotificationCompareResult(); FieldInfo[] _fieldInfos = typeof(NotificationCompareResult).GetFields(); for (int j = 0; j < resultClassColumns.Count; j++) { int _columnIndex = resultClassColumns[j]; string _param = notificationUnitStorage[indexArray[i]][_columnIndex]; _fieldInfos[j].SetValue(_compareResult, ConvertData(_param, _fieldInfos[j].FieldType)); } _result.Add(_compareResult); } } return(_result); }
private static bool PropertyCompare(string[] conditionTable, ConditionData compareObj) { Type _type = compareObj.GetType(); FieldInfo[] _fieldInfoArr = _type.GetFields(); List <bool> orList = new List <bool>(); List <bool> andList = new List <bool>(); for (int i = 0; i < conditionTable.Length; i++) { if (conditionTable[i] == CHAR_TAG_IGNORE) { continue; } object _compareParam = _fieldInfoArr[i].GetValue(compareObj); SubCompareResult _compare = SpecificCompare(conditionTable[i], _compareParam, _fieldInfoArr[i]); switch (_compare.logicTag) { case LogicalOperator.And: andList.Add(_compare.result); break; case LogicalOperator.Or: orList.Add(_compare.result); break; } } if ((orList == null || orList.Count <= 0) && (andList == null || andList.Count <= 0)) { return(false); } for (int i = 0; i < andList.Count; i++) { if (!andList[i]) { return(false); } } bool _or = false; for (int i = 0; i < orList.Count; i++) { if (orList[i]) { _or = true; } } return(_or); }