// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // using System.Collections.Generic; namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan { internal class XmlPlanHierarchyParser : XmlPlanParser { /// /// This function doesn't do anything. It simply returns the parent node /// passed it. /// /// Item being parsed. /// Parent item. /// Parent node. /// Node builder context. /// The node that corresponds to the item being parsed. public override Node GetCurrentNode(object item, object parentItem, Node parentNode, NodeBuilderContext context) { return parentNode; } /// /// Extracts FunctionType blocks. /// /// The item being parsed. /// Enumeration. public override IEnumerable ExtractFunctions(object parsedItem) { // Recursively call ExtractFunctions for each children. foreach (object item in GetChildren(parsedItem)) { XmlPlanParser parser = XmlPlanParserFactory.GetParser(item.GetType()); foreach (FunctionTypeItem functionItem in parser.ExtractFunctions(item)) { yield return functionItem; } } } /// /// Private constructor prevents this object from being externally instantiated /// protected XmlPlanHierarchyParser() { } /// /// Singelton instance /// private static XmlPlanHierarchyParser xmlPlanHierarchyParser = null; public static XmlPlanHierarchyParser Instance { get { if (xmlPlanHierarchyParser == null) { xmlPlanHierarchyParser = new XmlPlanHierarchyParser(); } return xmlPlanHierarchyParser; } } } }