예제 #1
0
        public PageViewModel(string urlAlias, IDataService dataService)
        {
            PageData pageData = dataService.GetPage(urlAlias);

            Zones = new List<ZoneViewModel>();

            foreach (ZoneData zoneData in pageData.Zones)
            {
                ZoneViewModel zone = new ZoneViewModel();
                Zones.Add(zone);
                foreach (WidgetData widgetData in zoneData.Widgets)
                {
                    string typeName = string.Format("Tardis.Model.Widgets.{0}, Tardis.Model", widgetData.Name);
                    Type type = Type.GetType(typeName, false, true);

                    GenericWidget widget = Activator.CreateInstance(type) as GenericWidget;
                    if (widget != null)
                    {
                        zone.Widgets.Add(widget);
                        widget.WidgetData = widgetData;
                        widget.DataService = dataService;
                        widget.Populate();
                    }
                }
            }
        }