/// <summary> /// Adds a <When /> element to the current <Choose /> element. /// </summary> /// <param name="condition">An optional condition to add to the <When /> element.</param> /// <param name="label">An optional label to add to the <When /> element.</param> /// <returns>The current <see cref="ProjectCreator"/>.</returns> public ProjectCreator When(string condition = null, string label = null) { ProjectChooseElement lastChoose = LastChoose; _lastWhen = RootElement.CreateWhenElement(condition); _lastWhen.Label = label; lastChoose.AppendChild(_lastWhen); _lastWhenPropertyGroup = null; _lastWhenItemGroup = null; return(this); }
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)); } }
protected override ProjectElement CreateChildElement(string name) { switch (name) { case "PropertyGroup": var property = RootElement.CreatePropertyGroupElement(); AppendChild(property); return(property); case "ItemGroup": var item = RootElement.CreateItemGroupElement(); AppendChild(item); return(item); case "When": var when = RootElement.CreateWhenElement(null); AppendChild(when); return(when); default: throw new InvalidProjectFileException(String.Format( "Child \"{0}\" is not a known node type.", name)); } }