Exemple #1
0
        private bool MakeNumericFilter(BookInfo 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);
                        Toast.MakeText(this.context, "Invalid input", ToastLength.Short).Show();
                    }
                    break;

                case "NotEquals":
                    try
                    {
                        if (Convert.ToDouble(FilterText) != Convert.ToDouble(exactValue))
                        {
                            return(true);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        Toast.MakeText(this.context, "Invalid input", ToastLength.Short).Show();
                        return(true);
                    }
                    break;
                }
            }
            return(false);
        }
        private bool MakeStringFilter(BookInfo 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.Any())
            {
                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 == "Not Equals")
                {
                    return(true);
                }
                return(false);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        private bool MakeNumericFilter(BookInfo 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) {
                        Debug.WriteLine(e.Message);
                    }
                    break;

                case "NotEquals":
                    try {
                        if (Convert.ToDouble(FilterText) != Convert.ToDouble(exactValue))
                        {
                            return(true);
                        }
                    } catch (Exception e) {
                        Debug.WriteLine(e.Message);
                        return(true);
                    }
                    break;
                }
            }
            return(false);
        }
		private bool MakeNumericFilter (BookInfo 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) {
                        Debug.WriteLine (e.Message);
					}
					break;
				case "NotEquals":
					try {
						if (Convert.ToDouble (FilterText) != Convert.ToDouble (exactValue))
							return true;
					} catch (Exception e) {
                        Debug.WriteLine(e.Message);
						return true;
					}
					break;
				}
			}
			return false;
		}
		private bool MakeStringFilter (BookInfo 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;
		}
		private bool MakeNumericFilter (BookInfo 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);
						Toast.MakeText (this.context, "Invalid input", ToastLength.Short).Show ();
					}
					break;
				case "NotEquals":
					try {
						if (Convert.ToDouble (FilterText) != Convert.ToDouble (exactValue))
							return true;
					} catch (Exception e) {
						Console.WriteLine (e);
						Toast.MakeText (this.context, "Invalid input", ToastLength.Short).Show ();
						return true;
					}
					break;
				}
			}
			return false;
		}