示例#1
0
        private bool MakeNumericFilter(BookDetails o, string option, string condition)
        {
            var value      = o.GetType().GetProperty(option);
            var exactValue = value.GetValue(o, null);

            exactValue = Regex.Replace(exactValue.ToString(), @"[^\d]", string.Empty);
            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);
        }
示例#2
0
        public ObservableCollection <BookDetails> GetBookDetails(int count)
        {
            ObservableCollection <BookDetails> bookDetails = new ObservableCollection <BookDetails>();

            for (int i = 1; i <= count; i++)
            {
                var ord = new BookDetails()
                {
                    BookID        = "Book ID : " + BookID[random.Next(8)].ToString(),
                    BookName      = "Book name : " + BookNames [random.Next(5)],
                    Price         = "Price : " + "$" + random.Next(30, 200).ToString(),
                    CustomerName  = "Name : " + CustomerNames[(i % 23)],
                    CustomerImage = ImageSource.FromResource("SampleBrowser.Icons.DataGrid.Image" + (i % 23) + ".png"),
                };
                bookDetails.Add(ord);
            }
            return(bookDetails);
        }
        public ObservableCollection <BookDetails> GetBookDetails(int count)
        {
            ObservableCollection <BookDetails> bookDetails = new ObservableCollection <BookDetails>();

            for (int i = 1; i <= count; i++)
            {
                var imageData = LoadResource("Image" + (i % 23) + ".png").ToArray();
                var ord       = new BookDetails()
                {
                    BookID        = BookID[r.Next(8)],
                    BookName      = BookNames[r.Next(5)],
                    Price         = r.Next(30, 200),
                    CustomerName  = CustomerNames[i % 23],
                    CustomerImage = BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length),
                };
                bookDetails.Add(ord);
            }
            return(bookDetails);
        }
示例#4
0
        private bool MakeNumericFilter(BookDetails o, string option, string condition)
        {
            var value      = o.GetType().GetRuntimeProperty(option);
            var exactValue = value.GetValue(o, null);

            exactValue = Regex.Replace(exactValue.ToString(), @"[^\d]", "");
            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);
        }
示例#5
0
        private bool MakeStringFilter(BookDetails 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);
            }
        }
示例#6
0
        public ObservableCollection <BookDetails> GetBookDetails(int count)
        {
            ObservableCollection <BookDetails> bookDetails = new ObservableCollection <BookDetails>();

            for (int i = 1; i <= count; i++)
            {
                var image         = LoadResource("Image" + (i % 23) + ".png").ToArray();
                var imageData     = NSData.FromArray(image);
                var customerImage = UIImage.LoadFromData(imageData, UIScreen.MainScreen.Scale);
                var ord           = new BookDetails()
                {
                    BookID        = BookID[random.Next(8)],
                    BookName      = BookNames[random.Next(5)],
                    Price         = random.Next(30, 200),
                    CustomerName  = CustomerNames[random.Next(7)],
                    CustomerImage = customerImage
                };
                bookDetails.Add(ord);
            }
            return(bookDetails);
        }