protected async virtual Task <SiteMapNode> LoadAsync() { var root = SiteMapNode.Empty; SiteMapNode node = root; var fInfo = _fileProvider.GetFileInfo(_fileName); if (fInfo.Exists) { XmlReaderSettings settings = new XmlReaderSettings() { Async = true }; using (var stream = new StreamReader(fInfo.CreateReadStream(), Encoding.UTF8)) using (XmlReader xmlReader = XmlReader.Create(stream, settings)) { while (await xmlReader.ReadAsync().ConfigureAwait(false)) { if (xmlReader.NodeType == XmlNodeType.Element) { if ("mvcSiteMapNode".Eq(xmlReader.Name)) { if (xmlReader.IsStartElement()) { if (!node.IsEmpty) { node = node.CreateChildren(); } } node.Title = xmlReader.GetAttribute("title"); string action = xmlReader.GetAttribute("action"); string controller = xmlReader.GetAttribute("controller"); string area = xmlReader.GetAttribute("area"); node.Uri = _urlHelper.Action(action: action, controller: controller, values: new { area = area }); node.AuthorizationPolicy = xmlReader.GetAttribute("policy"); node.LocalizationKey = xmlReader.GetAttribute("loc"); if (xmlReader.IsEmptyElement) { node = node.Parent; } } } else if (xmlReader.NodeType == XmlNodeType.EndElement) { if ("mvcSiteMapNode".Eq(xmlReader.Name) && node.Parent != null) { node = node.Parent; } } } } } return(root); }