Example #1
0
        public List <InternetShop> Get(InternetShopFilter filter)
        {
            List <InternetShop> ResultInternetShop = new List <InternetShop>();

            FilesProvider.OpenReader("InternetShop");

            int peek = FilesProvider.Peek();

            while (peek != -1)
            {
                string IdRow = FilesProvider.ReadRow();
                if (string.IsNullOrEmpty(IdRow))
                {
                    break;                              // means that if file is empty
                }
                string[] IdParts = IdRow.Split(':');
                int      id      = Convert.ToInt32(IdParts[1].Trim());


                string   NameRow   = FilesProvider.ReadRow();
                string[] NameParts = NameRow.Split(':');
                string   name      = NameParts[1].Trim();


                string   CategoryRow   = FilesProvider.ReadRow();
                string[] CategoryParts = NameRow.Split(':');
                string   category      = CategoryParts[1].Trim();

                string   PriceRow   = FilesProvider.ReadRow();
                string[] PriceParts = PriceRow.Split(':');
                string   price      = PriceParts[1].Trim();


                InternetShop Collection = new InternetShop(id, name, category, price);
                ResultInternetShop.Add(Collection);

                peek = FilesProvider.Peek();
                if (FilesProvider.ReadRow() == "")
                {
                    continue;
                }
            } // while

            FilesProvider.CloseReader();
            return(ResultInternetShop);
        }