Example #1
0
        public override void Run(IGUI guiHandler)
        {
            List <Smartphone> smartphones = InitMockList();

            guiHandler.PrintList(smartphones, "Telefoni disponibili", true);
            guiHandler.WriteMessage();

            //var grayPhones = smartphones.FilterBy(new FilterByColor(Color.DarkGray));
            var grayPhones = smartphones.FilterBy(x => x.Color == Color.DarkGray);

            guiHandler.PrintList(grayPhones, "Telefoni grigi", true);
            guiHandler.WriteMessage();

            //var economicPhones = smartphones.FilterBy(new FilterByCost(300m));
            var economicPhones = smartphones.FilterBy(x => x.Cost < 300m);

            guiHandler.PrintList(economicPhones, "Telefoni sotto i 300€", true);
        }
Example #2
0
        public override void Run(IGUI guiHandler)
        {
            guiHandler.PrintList(MockList, "Starting list");
            guiHandler.WriteMessage();

            #region Extensions example
            guiHandler.PrintList(MockList.ToRevertedStrings(), "Reverted elements list");
            guiHandler.WriteMessage();
            guiHandler.PrintList(MockList.ToLengthList(), "Elements length list");
            guiHandler.WriteMessage();
            guiHandler.PrintList(MockList.LessThanLength(3), "Elements shorter than 3");
            guiHandler.WriteMessage();
            guiHandler.PrintList(MockList.StartWithLetter('a'), "Elements beginning with a");
            guiHandler.WriteMessage();
            guiHandler.PrintList(MockList.IsConvertibleInInt(), "Elements convertible in int");
            guiHandler.WriteMessage();
            #endregion Extensions example

            #region Interface example
            guiHandler.WriteMessage("WITH INTERFACE");
            guiHandler.PrintList(MockList.Filter(new ShortStringFilter(3)), "Elements shorter than 3");
            guiHandler.WriteMessage();
            guiHandler.PrintList(MockList.Filter(new StartWithFilter('a')), "Elements beginning with a");
            guiHandler.WriteMessage();
            guiHandler.PrintList(MockList.Filter(new StringConvertibleToInt_Filter()), "Elements convertible in int");
            guiHandler.WriteMessage();

            guiHandler.PrintList(MockList.Project(new LenghtFromString_Projection()), "Elements length list");
            guiHandler.WriteMessage();
            guiHandler.PrintList(MockList.Project(new InvertedString_Projection()), "Reverted elements list");
            guiHandler.WriteMessage();
            #endregion Interface example

            #region Delegate example
            guiHandler.WriteMessage("WITH DELEGATES");
            guiHandler.PrintList(MockList.FilterBy(x => x != null && x.Length < 3), "Elements shorter than 3");
            guiHandler.WriteMessage();
            guiHandler.PrintList(MockList.FilterBy(x => x != null && (x.StartsWith("A") || x.StartsWith("a"))), "Elements beginning with a");
            guiHandler.WriteMessage();
            guiHandler.PrintList(MockList.FilterBy(x => x != null && int.TryParse(x, out int _)), "Elements convertible in int");
            guiHandler.WriteMessage();

            //guiHandler.PrintList(MockList.Project(new LenghtFromString_Projection()), "Elements length list");
            //guiHandler.WriteMessage();
            //guiHandler.PrintList(MockList.Project(new InvertedString_Projection()), "Reverted elements list");
            //guiHandler.WriteMessage();
            #endregion Delegate example

            guiHandler.AskForExit();
        }