public string[] GetBuildActions ()
{
if (buildActions != null)
return buildActions;
// find all the actions in use and add them to the list of standard actions
Hashtable actions = new Hashtable ();
object marker = new object (); //avoid using bools as they need to be boxed. re-use single object instead
//ad the standard actions
foreach (string action in GetStandardBuildActions ())
actions[action] = marker;
//add any more actions that are in the project file
foreach (ProjectFile pf in files)
if (!actions.ContainsKey (pf.BuildAction))
actions[pf.BuildAction] = marker;
//remove the "common" actions, since they're handled separately
IList<string> commonActions = GetCommonBuildActions ();
foreach (string action in commonActions)
if (actions.Contains (action))
actions.Remove (action);
//calculate dimensions for our new array and create it
int dashPos = commonActions.Count;
bool hasDash = commonActions.Count > 0 && actions.Count > 0;
int arrayLen = commonActions.Count + actions.Count;
int uncommonStart = hasDash ? dashPos + 1 : dashPos;
if (hasDash)
arrayLen++;
buildActions = new string[arrayLen];
//populate it
if (commonActions.Count > 0)
commonActions.CopyTo (buildActions, 0);
if (hasDash)
buildActions[dashPos] = "--";
if (actions.Count > 0)
actions.Keys.CopyTo (buildActions, uncommonStart);
//sort the actions
if (hasDash) {
//it may be better to leave common actions in the order that the project specified
//Array.Sort (buildActions, 0, commonActions.Count, StringComparer.Ordinal);
Array.Sort (buildActions, uncommonStart, arrayLen - uncommonStart, StringComparer.Ordinal);
} else {
Array.Sort (buildActions, StringComparer.Ordinal);
}
return buildActions;
}