private void GenerateRegion(BlockRegion region, RegionMap map) { _regionMappings[map] = region; foreach (RegionMap childRegion in map.ChildRegions) { if (childRegion.Type != RegionMap.RegionType.Try) { continue; } Zone newZone = new Zone(region); region.AddChildZone(newZone); newZone.TryRegion = new BlockRegion(BlockRegion.RegionType.Primary, newZone); GenerateRegion(newZone.TryRegion, childRegion); foreach (RegionMap associatedRegion in childRegion.AssociatedRegions) { switch (associatedRegion.Type) { case RegionMap.RegionType.Catch: BlockRegion catchRegion = new BlockRegion(BlockRegion.RegionType.Catch, newZone); GenerateRegion(catchRegion, associatedRegion); CatchCase catchCase = new CatchCase(_assemblyLoader.ResolveType(associatedRegion.CatchReference), catchRegion); newZone.AddCatchRegion(catchCase); break; case RegionMap.RegionType.Finally: if (newZone.FinalRegion != null) { throw new ArgumentException("Two final regions should not occur!"); } newZone.FinalRegion = new BlockRegion(BlockRegion.RegionType.Final, newZone); GenerateRegion(newZone.FinalRegion, associatedRegion); break; default: throw new ArgumentOutOfRangeException(); } } } }