Example #1
0
        public MainWindow()
        {
            InitializeComponent();

            var person = new Person{ Name = "Mario", Email = "*****@*****.**", Age = 31 };

            DataContext = new PersonHomeView(person, this);
        }
Example #2
0
 private void Add_Click(object sender, RoutedEventArgs e)
 {
     if (_treeList.SelectedNode != null)
     {
         var p = new Person() { Name = "NewPerson" };
         (_treeList.SelectedNode.Tag as Person).Children.Add(p);
         _treeList.SelectedNode.IsExpanded = true;
     }
 }
Example #3
0
 public static PersonModel CreateTestModel(int count1, int count2, int count3)
 {
     var model = new PersonModel();
     for (int i = 0; i < count1; i++)
     {
         var p = new Person() { Name = "Person A " + i.ToString() };
         model.Root.Children.Add(p);
         for (int n = 0; n < count2; n++)
         {
             var p2 = new Person() { Name = "Person B" + n.ToString() };
             p.Children.Add(p2);
             for (int k = 0; k < count3; k++)
                 p2.Children.Add(new Person() { Name = "Person C" + k.ToString() });
         }
     }
     return model;
 }
Example #4
0
        private void SimpleTest2()
        {
            IEnumerable<Person> family = new Person[]
            {
                new Person() { Age = 31, Gender = Gender.M, Name = "Andrey"
                    , Books = new Book[] {
                        new Book() { Title = "Alice", Author = "Caroll", Price = 9.99 },
                        new Book() { Title = "C#", Author = "Ben", Price = 19.99 } } },
                new Person() { Age = 6, Gender = Gender.M, Name = "Dima"
                    , Books = new Book[] {
                        new Book() { Title = "English", Author = "Teacher", Price = 7.00 } } },
                new Person() { Age = 30, Gender = Gender.F, Name = "Alena"
                    , Books = new Book[] {
                        new Book() { Title = "Sport", Author = "Arny", Price = 21.50 } } },
                new Person() { Age = 67, Gender = Gender.F, Name = "Elena" },
                new Person() { Age = 70, Gender = Gender.M, Name = "Boris" }
            };

            var query = from person in family
                        group person by person.Name
                            into gr
                            select new
                            {
                                Name = gr.Key,
                                AvgPrice = (from g in gr
                                            select g.Books == null ? 0 : g.Books.Average(b => b.Price)).Average()
                            };

            foreach (var item in query)
            {
                MessageBox.Show(item.Name.ToString() + " - " + item.AvgPrice.ToString());
            }
        }
Example #5
0
        private void SimpleTest()
        {
            IEnumerable<Person> family = new Person[]
            {
                new Person() { Age = 31, Gender = Gender.M, Name = "Andrey" },
                new Person() { Age = 6, Gender = Gender.M, Name = "Dima" },
                new Person() { Age = 30, Gender = Gender.F, Name = "Alena" },
                new Person() { Age = 67, Gender = Gender.F, Name = "Elena" },
                new Person() { Age = 70, Gender = Gender.M, Name = "Boris" }
            };

            var query = from person in family
                        group person by person.Gender
                            into gr
                            select new
                            {
                                Gender_ = gr.Key,
                                MaxAge = (from g in gr select g.Age).Average()
                            };

            foreach (var item in query)
            {
                MessageBox.Show(item.Gender_.ToString() + " - " + item.MaxAge.ToString());
            }
        }
Example #6
0
 public PersonModel()
 {
     Root = new Person();
 }