//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
{
///
/// Parses StmtCursorType ShowPlan XML nodes
///
internal class CursorOperationParser : XmlPlanParser
{
///
/// Creates new node and adds it to the graph.
///
/// 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 NewNode(context);
}
///
/// Determines Operation that corresponds to the object being parsed.
///
/// Node being parsed.
/// Operation that corresponds to the node.
protected override Operation GetNodeOperation(Node node)
{
object cursorOperationName = node["OperationType"];
Operation cursorOperation = cursorOperationName != null
? OperationTable.GetPhysicalOperation(cursorOperationName.ToString())
: Operation.Unknown;
return cursorOperation;
}
///
/// Determines node subtree cost from existing node properties.
///
/// Node being parsed.
/// Node subtree cost.
protected override double GetNodeSubtreeCost(Node node)
{
// This node doesn't have subtree cost, so it
// will be determined based on child nodes.
return 0;
}
///
/// Private constructor prevents this object from being externally instantiated
///
private CursorOperationParser()
{
}
///
/// Singelton instance
///
private static CursorOperationParser cursorOperationParser = null;
public static CursorOperationParser Instance
{
get
{
if (cursorOperationParser == null)
{
cursorOperationParser = new CursorOperationParser();
}
return cursorOperationParser;
}
}
}
}