void FindStartupItems(Solution sol, SolutionFolder folder, List <SolutionEntityItem> items)
        {
            CombineStartupMode startupMode = (CombineStartupMode)folder.ExtendedProperties ["StartMode"];

            if (startupMode != null)
            {
                if (startupMode.SingleStartup)
                {
                    SolutionItem it = FindItemByName(folder, startupMode.StartEntryName);
                    if (it is SolutionFolder)
                    {
                        FindStartupItems(sol, (SolutionFolder)it, items);
                    }
                    else if (it is SolutionEntityItem)
                    {
                        items.Add((SolutionEntityItem)it);
                    }
                    return;
                }
                else
                {
                    foreach (CombineStartupEntry cse in startupMode.Entries)
                    {
                        if (cse.Type == "Execute")
                        {
                            SolutionItem it = FindItemByName(folder, cse.Entry);
                            if (it is SolutionFolder)
                            {
                                FindStartupItems(sol, (SolutionFolder)it, items);
                            }
                            else if (it is SolutionEntityItem)
                            {
                                items.Add((SolutionEntityItem)it);
                            }
                        }
                    }
                }
            }
        }
        void CreateStartupModes(Solution sol)
        {
            // Initialize the startup modes
            ReadOnlyCollection <SolutionFolder> folders = sol.GetAllSolutionItems <SolutionFolder> ();

            foreach (SolutionFolder folder in folders)
            {
                CombineStartupMode startupMode = new CombineStartupMode();
                startupMode.SingleStartup  = true;
                startupMode.StartEntryName = null;
                foreach (SolutionItem it in folder.Items)
                {
                    startupMode.AddEntry(it.Name);
                }
                folder.ExtendedProperties ["StartMode"] = startupMode;
            }

            // Get the list of startup items
            IEnumerable <SolutionEntityItem> items;

            if (sol.SingleStartup)
            {
                items = new SolutionEntityItem [] { sol.StartupItem }
            }
            ;
            else
            {
                items = sol.MultiStartupItems;
            }

            // Setup the startup modes
            foreach (SolutionEntityItem it in items)
            {
                if (it == null)
                {
                    continue;
                }
                SolutionFolder folder   = it.ParentFolder;
                SolutionItem   prevItem = it;
                while (folder != null)
                {
                    CombineStartupMode startupMode = (CombineStartupMode)folder.ExtendedProperties ["StartMode"];
                    if (startupMode.SingleStartup)
                    {
                        // If a start entry is already set, convert to multi startup mode
                        if (startupMode.StartEntryName == null)
                        {
                            startupMode.StartEntryName = prevItem.Name;
                        }
                        else if (startupMode.StartEntryName != prevItem.Name)
                        {
                            startupMode.SingleStartup = false;
                            startupMode.MakeExecutable(startupMode.StartEntryName);
                            startupMode.MakeExecutable(prevItem.Name);
                        }
                    }
                    else
                    {
                        // Already multi startup, just add the new item
                        startupMode.MakeExecutable(prevItem.Name);
                    }
                    prevItem = folder;
                    folder   = folder.ParentFolder;
                }
            }

            // Set the startup item for folders which don't have one
            foreach (SolutionFolder folder in folders)
            {
                CombineStartupMode startupMode = (CombineStartupMode)folder.ExtendedProperties ["StartMode"];
                if (startupMode.SingleStartup && startupMode.StartEntryName == null)
                {
                    if (folder.Items.Count > 0)
                    {
                        startupMode.StartEntryName = folder.Items [0].Name;
                    }
                }
            }
        }
		void CreateStartupModes (Solution sol)
		{
			// Initialize the startup modes
			ReadOnlyCollection<SolutionFolder> folders = sol.GetAllSolutionItems<SolutionFolder> ();
			foreach (SolutionFolder folder in folders) {
				CombineStartupMode startupMode = new CombineStartupMode ();
				startupMode.SingleStartup = true;
				startupMode.StartEntryName = null;
				foreach (SolutionItem it in folder.Items)
					startupMode.AddEntry (it.Name);
				folder.ExtendedProperties ["StartMode"] = startupMode;
			}
			
			// Get the list of startup items
			IEnumerable<SolutionEntityItem> items;
			if (sol.SingleStartup)
				items = new SolutionEntityItem [] { sol.StartupItem };
			else
				items = sol.MultiStartupItems;

			// Setup the startup modes
			foreach (SolutionEntityItem it in items) {
				if (it == null)
					continue;
				SolutionFolder folder = it.ParentFolder;
				SolutionItem prevItem = it;
				while (folder != null) {
					CombineStartupMode startupMode = (CombineStartupMode) folder.ExtendedProperties ["StartMode"];
					if (startupMode.SingleStartup) {
						// If a start entry is already set, convert to multi startup mode
						if (startupMode.StartEntryName == null)
							startupMode.StartEntryName = prevItem.Name;
						else if (startupMode.StartEntryName != prevItem.Name) {
							startupMode.SingleStartup = false;
							startupMode.MakeExecutable (startupMode.StartEntryName);
							startupMode.MakeExecutable (prevItem.Name);
						}
					} else {
						// Already multi startup, just add the new item
						startupMode.MakeExecutable (prevItem.Name);
					}
					prevItem = folder;
					folder = folder.ParentFolder;
				}
			}
			
			// Set the startup item for folders which don't have one
			foreach (SolutionFolder folder in folders) {
				CombineStartupMode startupMode = (CombineStartupMode) folder.ExtendedProperties ["StartMode"];
				if (startupMode.SingleStartup && startupMode.StartEntryName == null) {
					if (folder.Items.Count > 0)
						startupMode.StartEntryName = folder.Items [0].Name;
				}
			}
		}