/// <summary> /// recrusively processes the xml file for breadcrumb nodes /// </summary> /// <param name="child">xml child node</param> /// <param name="tree">collection of breadcrumbs</param> private void ProcessChild(XmlNode child, TreeCollection <Breadcrumb>?tree) { if (child.NodeType != XmlNodeType.Element) { return; } var a = child.Attributes?.GetNamedItem("Action"); var c = child.Attributes?.GetNamedItem("Controller"); var f = child.Attributes?.GetNamedItem("Fragment"); var t = child.Attributes?.GetNamedItem("Text"); var type = child.Attributes?.GetNamedItem("Type")?.Value; if (a == null || c == null || t == null) { throw new XmlException("BreadCrumb node must contain 'Controller', 'Action', and 'Text' attributes"); } var node = new Breadcrumb(); if (type.IsNotBlank()) { var actualType = Type.GetType(type); node = (Breadcrumb)this.serviceProvider.GetService(actualType !) !; } node.Action = a.Value ?? string.Empty; node.Controller = c.Value ?? string.Empty; node.Text = t.Value ?? string.Empty; node.Fragment = f?.Value ?? string.Empty; tree = tree == null ? (this.root = new TreeCollection <Breadcrumb>(node)) : tree.AddChild(node); child.ChildNodes.Cast <XmlNode>() .ToList() .ForEach(n => this.ProcessChild(n, tree)); }