private static void ProcessElementLocationOption(ProjectElementContainer container, ElementLocationOption option, ProjectElement element) { switch (option) { case ElementLocationOption.BeforeFirstChild: { ProjectElement firstChild = container.FirstChild; container.InsertBeforeChild(element, firstChild); break; } case ElementLocationOption.AfterLastChild: { ProjectElement lastChild = container.FirstChild; container.InsertAfterChild(element, lastChild); break; } default: { return; } } }
public static ProjectImportElement Clone(this ProjectImportElement oldImport, ProjectRootElement newRoot, ElementLocationOption option = ElementLocationOption.None) { ProjectImportElement newImport = newRoot.CreateImportElement(oldImport.Project); if (!string.IsNullOrEmpty(oldImport.Condition)) { newImport.Condition = oldImport.Condition; } if (!string.IsNullOrEmpty(oldImport.Sdk)) { newImport.Sdk = oldImport.Sdk; } ProcessElementLocationOption(newRoot, option, newImport); return(newImport); }