Esempio n. 1
0
        public void AddUsers(Users users)
        {
            UsersItems.Add(users);
            ListBoxUsers.Items.Add(users.CxListBoxItem);
            var bindImg = new BindingImage();

            ListArrow.Add(bindImg);
        }
Esempio n. 2
0
 protected override void InitialiseArrow()
 {
     arrow = ListArrow.OrderBy((Person a, Person b) => b.Age - a.Age).Map((Person p) =>
     {
         return(new Person {
             Name = p.Name + " mapped", Age = p.Age + 1, Employer = p.Employer
         });
     });
 }
        public static ListArrow <A, C> Map <A, B, C>(this ListArrow <A, B> listArrow, Func <B, C> transformation)
        {
            /*
             * Append a MapArrow to the end of the supplied ListArrow using the transformation Func
             * passed in.
             */

            MapArrow <B, C> mapArrow = ListArrow.Map(transformation);

            return(listArrow.Combine(mapArrow));
        }
        public static ListArrow <A, B> Filter <A, B>(this ListArrow <A, B> listArrow, Func <B, bool> predicate)
        {
            /*
             * Append a FilterArrow to the end of the supplied ListArrow using the predicate passed
             * in.
             */

            FilterArrow <B> filterArrow = ListArrow.Filter(predicate);

            return(listArrow.Combine(filterArrow));
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Database data = new Database();

            ordersFromMicrosoft     = new ListOutput();
            ordersToCambridge       = new ListOutput();
            bulkOrders              = new ListOutput();
            averageOrdersToScotland = new IntOutput();

            BindingsManager.CreateBinding(
                data.GetBindPoint("orders"),
                ListArrow.Filter((Order x) => x.Supplier.Name == "Microsoft")
                .OrderBy((Order x, Order y) => x.Customer.Name.CompareTo(y.Customer.Name)),
                ordersFromMicrosoft.GetBindPoint("Orders"));

            BindingsManager.CreateBinding(
                data.GetBindPoint("orders"),
                ListArrow.Filter((Order x) => x.Customer.Location == "Cambridge")
                .OrderBy((Order x, Order y) => x.Customer.Name.CompareTo(y.Customer.Name)),
                ordersToCambridge.GetBindPoint("Orders"));

            BindingsManager.CreateBinding(
                data.GetBindPoint("orders"),
                ListArrow.Filter((Order x) => x.Volume > 30)
                .OrderBy((Order x, Order y) => x.Customer.Name.CompareTo(y.Customer.Name)),
                bulkOrders.GetBindPoint("Orders"));

            var averagingArrow = Op.Split <IEnumerable <int> >()
                                 .Combine(Op.And(
                                              ListArrow.Foldl((int x, int y) => x + y, 0),
                                              ListArrow.Foldl((int x, int y) => x + 1, 0)))
                                 .Unsplit((int total, int count) => total / count);

            BindingsManager.CreateBinding(
                data.GetBindPoint("orders"),
                ListArrow.Filter((Order x) => x.Customer.Location == "Glasgow" || x.Customer.Location == "Aberdeen")
                .Map((Order x) => x.Volume)
                .Combine(averagingArrow),
                averageOrdersToScotland.GetBindPoint("Result"));

            data.Initialise();

            PrintOutput("Orders from Microsoft", ordersFromMicrosoft);
            PrintOutput("Orders to Cambridge", ordersToCambridge);
            PrintOutput("Bulk orders", bulkOrders);
            Console.WriteLine("Average orders to Scotland: {0}", averageOrdersToScotland.Result);
            Console.WriteLine();

            IncreaseMoragsOrder(data);
            MoveBrendaToCambridge(data);
            MicrosoftTakeover(data);
        }
        public static ListArrow <A, C> Combine <A, B, C>(this ListArrow <A, B> a1, ListArrow <B, C> a2)
        {
            /*
             * Combine arrows end-to-end. This is an overloaded version of the normal Arrow.Combine
             * method used to prevent ListArrows being prematurely converted into arrows between
             * IEnumerables.
             */

            ListArrow <A, C> result = new ListArrow <A, C>(
                x => a2.Invoke(a1.Invoke(x))
                );

            return(result);
        }
Esempio n. 7
0
 protected override void InitialiseArrow()
 {
     Arrow<IEnumerable<Person>, Person> tempArrow = ListArrow.Foldl((Person a, Person b) =>
         new Person
         {
             Age = a.Age + b.Age,
             Name = String.Format("{0} and {1}", a.Name, b.Name),
             Employer = a.Employer
         },
             new Person
             {
                 Name = "",
                 Age = 0,
                 Employer = new Employer { Name = "Employer", Size = 10 }
             });
     arrow = new ListArrow<Person, Person>(
         x => new List<Person> {tempArrow.Invoke(x)});
 }
Esempio n. 8
0
        public static void DemoListArrows()
        {
            List <String> cities = new List <String> {
                "London",
                "Edinburgh",
                "Newcastle",
                "Manchester",
                "Glasgow",
                "Cambridge"
            };

            ListArrow <String, String> sorter = ListArrow.Map((String x) => Tuple.Create(x, x.Length))
                                                .Combine(ListArrow.OrderBy <Tuple <String, int> >((s1, s2) => s1.Item2 - s2.Item2)
                                                         .Combine(ListArrow.Map((Tuple <String, int> x) => x.Item1)))
                                                .Combine(ListArrow.Filter((String x) => x.IndexOf('E') != 0));

            var result = sorter.Invoke(cities);

            foreach (var s in result)
            {
                Console.WriteLine(s);
            }

            Console.WriteLine();

            ListArrow <String, String> cityArrow =
                ListArrow.Map((String city) => Tuple.Create(city, city.Length))
                .Filter((Tuple <String, int> cityTuple) => cityTuple.Item2 > 7)
                .Map((Tuple <String, int> cityTuple) => cityTuple.Item1)
                .Filter((String city) => city != "Manchester")
                .OrderBy((String c1, String c2) => c1.CompareTo(c2));

            result = cityArrow.Invoke(cities);
            foreach (var s in result)
            {
                Console.WriteLine(s);
            }
        }
Esempio n. 9
0
        protected override void InitialiseArrow()
        {
            Arrow <IEnumerable <Person>, Person> tempArrow = ListArrow.Foldl((Person a, Person b) =>
                                                                             new Person
            {
                Age      = a.Age + b.Age,
                Name     = String.Format("{0} and {1}", a.Name, b.Name),
                Employer = a.Employer
            },
                                                                             new Person
            {
                Name     = "",
                Age      = 0,
                Employer = new Employer {
                    Name = "Employer", Size = 10
                }
            });

            arrow = new ListArrow <Person, Person>(
                x => new List <Person> {
                tempArrow.Invoke(x)
            });
        }
Esempio n. 10
0
 protected override void InitialiseArrow()
 {
     arrow = ListArrow.Filter((Person p) => p.Age > 10);
 }
Esempio n. 11
0
 public void InitialiseArrow()
 {
     arrow = ListArrow.Filter <Order>((Order o) => o.Volume > 1)
             .Map((Order o) => String.Format("Order from {0} in {1} for {2} {3}s from {4}", o.Customer.Name, o.Customer.Location, o.Volume, o.Product, o.Supplier.Name));
 }
 public void InitialiseArrow()
 {
     arrow = ListArrow.Filter<Order>((Order o) => o.Volume > 1)
         .Map((Order o) => String.Format("Order from {0} in {1} for {2} {3}s from {4}", o.Customer.Name, o.Customer.Location, o.Volume, o.Product, o.Supplier.Name));
 }
        public static Arrow <IEnumerable <A>, B> Foldr <A, B>(this ListArrow <A, B> listArrow, Func <B, B, B> fold, B zero)
        {
            Arrow <IEnumerable <B>, B> foldArrow = ListArrow.Foldl(fold, zero);

            return(listArrow.Combine(foldArrow));
        }
        public static ListArrow <A, B> Reverse <A, B>(this ListArrow <A, B> listArrow)
        {
            ReverseArrow <B> reverseArrow = ListArrow.Reverse <B>();

            return(listArrow.Combine(reverseArrow));
        }
        public static ListArrow <A, B> OrderBy <A, B>(this ListArrow <A, B> listArrow, Func <B, B, int> comparer)
        {
            OrderByArrow <B> orderByArrow = ListArrow.OrderBy(comparer);

            return(listArrow.Combine(orderByArrow));
        }