Esempio n. 1
0
        private static void WriteTo(IndentedTextWriter textWriter, ShowPlanElement element)
        {
            textWriter.Write("[");
            textWriter.Write(element.Operator);
            textWriter.Write("]");
            textWriter.WriteLine();

            // Write properties

            foreach (ShowPlanProperty property in element.Properties)
            {
                textWriter.Write(property.FullName);
                textWriter.Write(" = ");
                textWriter.Write(property.Value);
                textWriter.WriteLine();
            }

            // Write Children

            textWriter.Indent++;
            foreach (ShowPlanElement child in element.Children)
            {
                WriteTo(textWriter, child);
            }
            textWriter.Indent--;
        }
Esempio n. 2
0
        private static ShowPlanElement ReadPlanElement(XPathNavigator elementNavigator)
        {
            ShowPlanOperator op = (ShowPlanOperator)Enum.Parse(typeof(ShowPlanOperator), elementNavigator.GetAttribute("operator", String.Empty));

            List <ShowPlanProperty> properties = new List <ShowPlanProperty>();

            foreach (XPathNavigator propertyNavigator in elementNavigator.Select("properties/property"))
            {
                string           propertyName  = propertyNavigator.GetAttribute("name", String.Empty);
                string           propertyValue = propertyNavigator.GetAttribute("value", String.Empty);
                ShowPlanProperty property      = new ShowPlanProperty(propertyName, propertyValue);
                properties.Add(property);
            }

            List <ShowPlanElement> children = new List <ShowPlanElement>();

            foreach (XPathNavigator childNode in elementNavigator.Select("input/*"))
            {
                ShowPlanElement childElement = ReadPlanElement(childNode);
                children.Add(childElement);
            }

            ShowPlanElement element = new ShowPlanElement(op, properties, children);

            return(element);
        }
Esempio n. 3
0
        /// <summary>
        /// Loads an execution plan from an XML document.
        /// </summary>
        /// <param name="navigable">An XPath navigable object to load the execution plan from</param>
        public static ShowPlan FromXml(IXPathNavigable navigable)
        {
            if (navigable == null)
            {
                throw ExceptionBuilder.ArgumentNull("navigable");
            }

            XPathNavigator  navigator = navigable.CreateNavigator();
            ShowPlanElement root      = ReadPlanElement(navigator.SelectSingleNode("executionPlan/element"));

            return(new ShowPlan(root));
        }
Esempio n. 4
0
        private static void WriteTo(XmlNode parent, ShowPlanElement element)
        {
            XmlNode elementNode = parent.OwnerDocument.CreateElement("element");

            parent.AppendChild(elementNode);

            XmlAttribute operatorAtt = parent.OwnerDocument.CreateAttribute("operator");

            operatorAtt.Value = element.Operator.ToString();
            elementNode.Attributes.Append(operatorAtt);

            XmlNode propertiesNode = parent.OwnerDocument.CreateElement("properties");

            elementNode.AppendChild(propertiesNode);

            foreach (ShowPlanProperty property in element.Properties)
            {
                XmlNode propertyNode = parent.OwnerDocument.CreateElement("property");
                propertiesNode.AppendChild(propertyNode);

                XmlAttribute propertyNameAtt = parent.OwnerDocument.CreateAttribute("name");
                propertyNameAtt.Value = property.FullName;
                propertyNode.Attributes.Append(propertyNameAtt);

                XmlAttribute propertyValueAtt = parent.OwnerDocument.CreateAttribute("value");
                propertyValueAtt.Value = property.Value;
                propertyNode.Attributes.Append(propertyValueAtt);
            }

            XmlNode inputNode = parent.OwnerDocument.CreateElement("input");

            elementNode.AppendChild(inputNode);

            foreach (ShowPlanElement child in element.Children)
            {
                WriteTo(inputNode, child);
            }
        }
Esempio n. 5
0
        internal static ShowPlan Build(AlgebraNode root)
        {
            ShowPlanElement rootElement = ShowPlanBuilder.Convert(root);

            return(new ShowPlan(rootElement));
        }
Esempio n. 6
0
 private ShowPlan(ShowPlanElement root)
 {
     _root = root;
 }
Esempio n. 7
0
		private static void WriteTo(XmlNode parent, ShowPlanElement element)
		{
			XmlNode elementNode = parent.OwnerDocument.CreateElement("element");
			parent.AppendChild(elementNode);

			XmlAttribute operatorAtt = parent.OwnerDocument.CreateAttribute("operator");
			operatorAtt.Value = element.Operator.ToString();
			elementNode.Attributes.Append(operatorAtt);

			XmlNode propertiesNode = parent.OwnerDocument.CreateElement("properties");
			elementNode.AppendChild(propertiesNode);

			foreach (ShowPlanProperty property in element.Properties)
			{
				XmlNode propertyNode = parent.OwnerDocument.CreateElement("property");
				propertiesNode.AppendChild(propertyNode);

				XmlAttribute propertyNameAtt = parent.OwnerDocument.CreateAttribute("name");
				propertyNameAtt.Value = property.FullName;
				propertyNode.Attributes.Append(propertyNameAtt);

				XmlAttribute propertyValueAtt = parent.OwnerDocument.CreateAttribute("value");
				propertyValueAtt.Value = property.Value;
				propertyNode.Attributes.Append(propertyValueAtt);
			}

			XmlNode inputNode = parent.OwnerDocument.CreateElement("input");
			elementNode.AppendChild(inputNode);

			foreach (ShowPlanElement child in element.Children)
			{
				WriteTo(inputNode, child);
			}
		}
Esempio n. 8
0
		private static ShowPlanElement ReadPlanElement(XPathNavigator elementNavigator)
		{
			ShowPlanOperator op = (ShowPlanOperator) Enum.Parse(typeof(ShowPlanOperator), elementNavigator.GetAttribute("operator", String.Empty));

			List<ShowPlanProperty> properties = new List<ShowPlanProperty>();
			foreach (XPathNavigator propertyNavigator in elementNavigator.Select("properties/property"))
			{
				string propertyName = propertyNavigator.GetAttribute("name", String.Empty);
				string propertyValue = propertyNavigator.GetAttribute("value", String.Empty);
				ShowPlanProperty property = new ShowPlanProperty(propertyName, propertyValue);
				properties.Add(property);
			}

			List<ShowPlanElement> children = new List<ShowPlanElement>();
			foreach (XPathNavigator childNode in elementNavigator.Select("input/*"))
			{
				ShowPlanElement childElement = ReadPlanElement(childNode);
				children.Add(childElement);
			}

			ShowPlanElement element = new ShowPlanElement(op, properties, children);
			return element;
		}
Esempio n. 9
0
		private ShowPlan(ShowPlanElement root)
		{
			_root = root;
		}
Esempio n. 10
0
		private static void WriteTo(IndentedTextWriter textWriter, ShowPlanElement element)
		{
			textWriter.Write("[");
			textWriter.Write(element.Operator);
			textWriter.Write("]");
			textWriter.WriteLine();

			// Write properties
			
			foreach (ShowPlanProperty property in element.Properties)
			{
				textWriter.Write(property.FullName);
				textWriter.Write(" = ");
				textWriter.Write(property.Value);
				textWriter.WriteLine();
			}

			// Write Children

			textWriter.Indent++;
			foreach (ShowPlanElement child in element.Children)
				WriteTo(textWriter, child);
			textWriter.Indent--;
		}