Exemplo n.º 1
0
        public PageLayout(
            PageElementDependencies dependencies,
            PageElement parent,
            ILayout layout,
            IEnumerable <Tuple <string, IRegion, IElement> > regionElements,
            IPageData pageData)
            : base(dependencies, parent, layout, pageData)
        {
            pageData.BeginAddElement(Element);

            _zones = dependencies.DictionaryFactory.Create <string, PageZone>(StringComparer.OrdinalIgnoreCase);

            var regionElementList = regionElements == null
                ? new List <Tuple <string, IRegion, IElement> >()
                : regionElements.ToList();

            foreach (var zoneName in layout.GetZoneNames())
            {
                var name          = zoneName;
                var regionElement = regionElementList.FirstOrDefault(
                    re => string.Equals(re.Item1, name, StringComparison.OrdinalIgnoreCase));

                var region = regionElement == null?layout.GetRegion(name) : regionElement.Item2;

                var element = regionElement == null?layout.GetElement(name) : regionElement.Item3;

                var pageRegion = new PageZone(dependencies, this, region, element, pageData);
                _zones[zoneName] = pageRegion;
            }

            Children = _zones.Values.ToArray();

            pageData.EndAddElement(Element);
        }