/// <summary>Perform the command</summary> /// <param name="commandHistory">The command history.</param> public void Do(CommandHistory commandHistory) { try { parent = presenter.ApsimXFile.FindByPath(parentPath)?.Value as IModel; if (parent == null) { throw new Exception("Cannot find model " + parentPath); } if (xmlOrJson != null) { modelToAdd = Structure.Add(xmlOrJson, parent); } else { modelToAdd = Structure.Add(child, parent); } presenter.AddChildToTree(parentPath, modelToAdd); modelAdded = true; } catch (Exception err) { presenter.MainPresenter.ShowError(err); modelAdded = false; } }