protected override ProjectElement CreateChildElement(string name) { switch (name) { case "When": var when = RootElement.CreateWhenElement(null); PrependChild(when); return(when); case "Otherwise": var other = RootElement.CreateOtherwiseElement(); AppendChild(other); return(other); default: throw new InvalidOperationException(String.Format( "Child \"{0}\" is not a known node type.", name)); } }
/// <summary> /// Adds an <Otherwise /> element to the current project. /// </summary> /// <param name="label">An optional label to add to the Otherwise.</param> /// <returns>The current <see cref="ProjectCreator"/>.</returns> /// <exception cref="ProjectCreatorException">A <When /> element has not been added /// -or- /// An <Otherwise /> has already been added to the current <Choose /> element.</exception> public ProjectCreator Otherwise(string label = null) { if (_lastWhen == null) { throw new ProjectCreatorException(Strings.ErrorOtherwiseRequiresWhen); } if (_lastChoose.OtherwiseElement != null) { throw new ProjectCreatorException(Strings.ErrorOtherwiseCanOnlyBeSetOnce); } ProjectOtherwiseElement projectOtherwiseElement = RootElement.CreateOtherwiseElement(); projectOtherwiseElement.Label = label; LastChoose.AppendChild(projectOtherwiseElement); return(this); }