private bool MakeNumericFilter(Eva_planeacion_temas o, string option, string condition) { var value = o.GetType().GetProperty(option); var exactValue = value.GetValue(o, null); double res; bool checkNumeric = double.TryParse(exactValue.ToString(), out res); if (checkNumeric) { switch (condition) { case "Equals": try { if (exactValue.ToString() == FilterText) { if (Convert.ToDouble(exactValue) == (Convert.ToDouble(FilterText))) { return(true); } } } catch (Exception e) { Console.WriteLine(e); } break; case "NotEquals": try { if (Convert.ToDouble(FilterText) != Convert.ToDouble(exactValue)) { return(true); } } catch (Exception e) { Console.WriteLine(e); return(true); } break; } } return(false); }
private bool MakeStringFilter(Eva_planeacion_temas o, string option, string condition) { var value = o.GetType().GetProperty(option); var exactValue = value.GetValue(o, null); exactValue = exactValue.ToString().ToLower(); string text = FilterText.ToLower(); var methods = typeof(string).GetMethods(); if (methods.Count() != 0) { if (condition == "Contains") { var methodInfo = methods.FirstOrDefault(method => method.Name == condition); bool result1 = (bool)methodInfo.Invoke(exactValue, new object[] { text }); return(result1); } else if (exactValue.ToString() == text.ToString()) { bool result1 = String.Equals(exactValue.ToString(), text.ToString()); if (condition == "Equals") { return(result1); } else if (condition == "NotEquals") { return(false); } } else if (condition == "NotEquals") { return(true); } return(false); } else { return(false); } }