main
 1using System;
 2using System.Collections.Generic;
 3using System.Windows;
 4using gorilla.commons.utility;
 5
 6namespace presentation.windows.views
 7{
 8    public partial class ShellWindow : RegionManager
 9    {
10        readonly IDictionary<Type, UIElement> regions;
11
12        public ShellWindow()
13        {
14            InitializeComponent();
15            regions = new Dictionary<Type, UIElement>
16                      {
17                          {GetType(), this},
18                          {typeof (Window), this},
19                          {Tabs.GetType(), Tabs},
20                          {StatusBar.GetType(), StatusBar},
21                          {Menu.GetType(), Menu},
22                          {SelectedFamilyMember.GetType(), SelectedFamilyMember},
23                      };
24        }
25
26        public void region<Region>(Action<Region> configure) where Region : UIElement
27        {
28            ensure_that_the_region_exists<Region>();
29            configure(regions[typeof (Region)].downcast_to<Region>());
30        }
31
32        void ensure_that_the_region_exists<Region>()
33        {
34            if (!regions.ContainsKey(typeof (Region)))
35                throw new Exception("Could not find region: {0}".format(typeof (Region)));
36        }
37    }
38}