private static Attempt <XmlTree> TryGetXmlTree(this ApplicationTree appTree, string id, FormDataCollection formCollection) { var treeDefAttempt = appTree.TryGetLegacyTreeDef(); if (treeDefAttempt.Success == false) { return(Attempt <XmlTree> .Fail(treeDefAttempt.Exception)); } var treeDef = treeDefAttempt.Result; //This is how the legacy trees worked.... var bTree = treeDef.CreateInstance(); var treeParams = new LegacyTreeParams(formCollection); //we currently only support an integer id or a string id, we'll refactor how this works //later but we'll get this working first int startId; if (int.TryParse(id, out startId)) { treeParams.StartNodeID = startId; } else { treeParams.NodeKey = id; } var xTree = new XmlTree(); bTree.SetTreeParameters(treeParams); bTree.Render(ref xTree); return(Attempt.Succeed(xTree)); }
internal static Attempt <XmlTreeNode> TryGetRootXmlNodeFromLegacyTree(this ApplicationTree appTree, FormDataCollection formCollection, UrlHelper urlHelper) { var treeDefAttempt = appTree.TryGetLegacyTreeDef(); if (treeDefAttempt.Success == false) { return(Attempt <XmlTreeNode> .Fail(treeDefAttempt.Exception)); } var treeDef = treeDefAttempt.Result; var bTree = treeDef.CreateInstance(); var treeParams = new LegacyTreeParams(formCollection); bTree.SetTreeParameters(treeParams); var xmlRoot = bTree.RootNode; return(Attempt.Succeed(xmlRoot)); }