private bool MakeStringFilter(EmployeeViewModel o, string option, string condition) { var value = (o.GetType().GetTypeInfo()).GetDeclaredProperty(option); var exactValue = value.GetValue(o); exactValue = exactValue.ToString().ToLower(); string text = FilterText.ToLower(); var methods = (typeof(string).GetTypeInfo()).GetDeclaredMethods(condition); if (methods.Count() != 0) { var methodInfo = methods.FirstOrDefault(); bool result1 = (bool)methodInfo.Invoke(exactValue, new object[] { text }); return result1; } else return false; }
private bool MakeNumericFilter(EmployeeViewModel o, string option, string condition) { var value = (o.GetType().GetTypeInfo()).GetDeclaredProperty(option); var exactValue = value.GetValue(o); double res; bool checkNumeric = double.TryParse(exactValue.ToString(), out res); if (checkNumeric) { switch (condition) { case "Equals": if (Convert.ToDouble(exactValue) == (Convert.ToDouble(FilterText))) return true; break; case "GreaterThan": if (Convert.ToDouble(exactValue) > Convert.ToDouble(FilterText)) return true; break; case "LessThan": if (Convert.ToDouble(exactValue) < Convert.ToDouble(FilterText)) return true; break; case "NotEquals": if (Convert.ToDouble(FilterText) != Convert.ToDouble(exactValue)) return true; break; } } return false; }