private void SetRegionInstances(ZoneSet zoneSet) { if (zoneSet == null || zoneSet.Zones == null) { return; } foreach (var region in zoneSet.Zones) { if (region.Region != null) { IElement regionContent = null; if (_regionComponents.ContainsKey(region.ZoneName)) { regionContent = _regionComponents[region.ZoneName] as IElement; } if (_regionLayouts.ContainsKey(region.ZoneName)) { regionContent = _regionLayouts[region.ZoneName] as IElement; } _layout.PopulateElement(region.ZoneName, regionContent); } if (region.ChildZones != null) { SetRegionInstances(region.ChildZones); } } }
public static ZoneSet Parse(string zones, ref int position) { var result = new ZoneSet { Zones = new List <ZoneSetRegion>() }; var start = position; while (position < zones.Length) { switch (zones[position]) { case '(': result.Zones.AddRange(BuildList(zones, start, position)); position++; result.Zones.Add(new ZoneSetRegion { ChildZones = Parse(zones, ref position) }); position++; start = position; break; case ')': result.Zones.AddRange(BuildList(zones, start, position)); return(result); default: position++; break; } } result.Zones.AddRange(BuildList(zones, start, position)); return(result); }
ILayoutDefinition ILayoutDefinition.ZoneNesting(string zoneNesting) { var position = 0; _zoneSet = ZoneSet.Parse(zoneNesting, ref position); return(this); }
private void ResolveZoneNames(ZoneSet zoneSet, INameManager nameManager) { if (zoneSet == null || zoneSet.Zones == null) { return; } foreach (var region in zoneSet.Zones) { if (region.Region == null) { if (region.RegionElementName == null) { if (region.ZoneName != null) { object element; if (_regionElements.TryGetValue(region.ZoneName, out element)) { region.RegionElementName = element as string; region.Region = element as IRegion; } } } if (region.RegionElementName != null && region.Region == null) { region.Region = nameManager.ResolveRegion(region.RegionElementName, _layout.Package); } } if (region.Region == null && region.ZoneName != null) { region.Region = new LayoutZoneRegion(_regionDependenciesFactory); } if (region.ZoneName != null) { _layout.PopulateZone(region.ZoneName, region.Region); } if (region.ChildZones != null) { ResolveZoneNames(region.ChildZones, nameManager); } } }
private void WriteRegions(ZoneSet zoneSet) { if (zoneSet == null || zoneSet.Zones == null) { return; } foreach (var region in zoneSet.Zones) { if (region.ZoneName != null) { _layout.AddZoneVisualElement(region.ZoneName); } if (region.ChildZones != null) { WriteNestingOpeningTag(); WriteRegions(region.ChildZones); WriteNestingClosingTag(); } } }