Beispiel #1
0
        private void ProcessElement(XPathNavigator navigator)
        {
            //TODO: prob a better way of doing this using the navigator
            if (!isFirstElement)
            {
                textWriter.Write(Environment.NewLine);
            }
            isFirstElement = false;
            WriteIndent();
            if (navigator.LocalName.ToLower() == "pre")
            {
                isInsidePre = true;
            }
            if (navigator.LocalName == "div")
            {
                var temp = navigator.CreateNavigator();
                if (temp.MoveToAttribute("id", null))
                {
                    textWriter.Write("#");
                    textWriter.Write(temp.Value);
                }
                else if (temp.MoveToAttribute("class", null))
                {
                    var strings = temp.Value.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var s in strings)
                    {
                        textWriter.Write(".");
                        textWriter.Write(s);
                    }
                }
                else
                {
                    textWriter.Write("%div");
                }
            }
            else if (navigator.Prefix == string.Empty)
            {
                textWriter.Write("%{0}", navigator.LocalName);
                CheckForAndAppendClass(navigator);
            }
            //else
            //{
            //TODO:
            //Console.Write(" <{0}:{1}>",oNavigator.Prefix,oNavigator.LocalName);
            //Console.WriteLine("\t" + oNavigator.NamespaceURI);
            //}

            var attributeNavigator = navigator.CreateNavigator();

            ProcessAttributes(attributeNavigator);

            indent++;
        }
Beispiel #2
0
        /// <summary>
        /// Updates the node replacing inheritdoc node with comments found.
        /// </summary>
        /// <param name="inheritDocNodeNavigator">Navigator for inheritdoc node</param>
        /// <param name="contentNodeNavigator">Navigator for content</param>
        private void UpdateNode(XPathNavigator inheritDocNodeNavigator, XPathNavigator contentNodeNavigator)
        {
            // retrieve the selection filter if specified.
            string selectValue = inheritDocNodeNavigator.GetAttribute("select", string.Empty);

            if (!string.IsNullOrEmpty(selectValue))
            {
                sourceExpression = XPathExpression.Compile(selectValue);
            }

            inheritDocNodeNavigator.MoveToParent();

            if (inheritDocNodeNavigator.LocalName != "comments" && inheritDocNodeNavigator.LocalName != "element")
            {
                sourceExpression = XPathExpression.Compile(inheritDocNodeNavigator.LocalName);
            }
            else
            {
                inheritDocNodeNavigator.MoveTo(this.sourceDocument.CreateNavigator().SelectSingleNode(inheritDocExpression));
            }

            XPathNodeIterator sources = (XPathNodeIterator)contentNodeNavigator.CreateNavigator().Evaluate(sourceExpression);

            inheritDocNodeNavigator.DeleteSelf();

            // append the source nodes to the target node
            foreach (XPathNavigator source in sources)
            {
                inheritDocNodeNavigator.AppendChild(source);
            }
        }
Beispiel #3
0
        public override XPathNavigator CreateNavigator()
        {
            var r1 = _nav1.CreateNavigator();
            var r2 = _nav2.CreateNavigator();

            return(new NavigatorComparer(r1, r2));
        }
        public string PeekType()
        {
            XPathNavigator peekingNavigator = navigator.CreateNavigator();

            peekingNavigator.MoveToFirstChild();
            return(peekingNavigator.LocalName);
        }
        /// <summary>
        /// Updates the node replacing inheritdoc node with comments found.
        /// </summary>
        /// <param name="inheritDocNodeNavigator">Navigator for inheritdoc node</param>
        /// <param name="contentNodeNavigator">Navigator for content</param>
        private void UpdateNode(XPathNavigator inheritDocNodeNavigator, XPathNavigator contentNodeNavigator)
        {
            // retrieve the selection filter if specified.
            string selectValue = inheritDocNodeNavigator.GetAttribute("select", String.Empty);

            if (!String.IsNullOrEmpty(selectValue))
            {
                this.WriteMessage(MessageLevel.Info, "Filter: " + selectValue);
                sourceExpression = XPathExpression.Compile(selectValue);
            }

            inheritDocNodeNavigator.MoveToParent();

            bool isInnerText = false;

            if (inheritDocNodeNavigator.LocalName != "comments" &&
                inheritDocNodeNavigator.LocalName != "element")
            {
                sourceExpression = XPathExpression.Compile(inheritDocNodeNavigator.LocalName);

                isInnerText = true;
            }
            else
            {
                inheritDocNodeNavigator.MoveTo(
                    this.sourceDocument.CreateNavigator().SelectSingleNode(inheritDocExpression));
            }

            XPathNodeIterator sources =
                (XPathNodeIterator)contentNodeNavigator.CreateNavigator().Evaluate(sourceExpression);

            if (isInnerText && sources.Count == 1)
            {
                //inheritDocNodeNavigator.DeleteSelf();
                inheritDocNodeNavigator.MoveTo(
                    this.sourceDocument.CreateNavigator().SelectSingleNode(inheritDocExpression));

                // append the source nodes to the target node
                foreach (XPathNavigator source in sources)
                {
                    inheritDocNodeNavigator.ReplaceSelf(source.InnerXml);
                }
            }
            else
            {
                inheritDocNodeNavigator.DeleteSelf();

                // append the source nodes to the target node
                foreach (XPathNavigator source in sources)
                {
                    XPathNodeIterator childIterator = inheritDocNodeNavigator.SelectChildren(
                        source.Name, String.Empty);
                    if (childIterator.Count == 0)
                    {
                        inheritDocNodeNavigator.AppendChild(source);
                    }
                }
            }
        }
Beispiel #6
0
        public Vector GetVector(XPathNavigator root)
        {
            XmlNamespaceManager nsm       = FhirNamespaceManager.CreateManager(root);
            Structure           structure = specification.GetStructureByName(root.Name);
            XPathNavigator      node      = root.CreateNavigator();

            return(Vector.Create(structure, node, nsm));
        }
        private void WriteNextNode(XmlWriter writer, XPathNavigator nav, bool iterateSiblings)
        {
            if (nav.Name == "ScatterFile")
            {
                writer.WriteStartElement(nav.Name, nav.NamespaceURI);
            }
            else
            {
                writer.WriteStartElement(nav.Name);
            }

            XPathNavigator attrib = nav.CreateNavigator();

            if (attrib.MoveToFirstAttribute())
            {
                do
                {
                    writer.WriteAttributeString(attrib.Name, attrib.Value);
                }while (attrib.MoveToNextAttribute());
            }

            if (nav.Name == "LoadRegion")
            {
                string lrName = nav.GetAttribute("Name", "");

                foreach (ExecRegion er in (m_execRegionOrderMap[lrName] as SortedList).Values)
                {
                    WriteNextNode(writer, m_execRegionsToNavNode[lrName + ":" + er.Name] as XPathNavigator, false);
                }
            }

            /*
             * else if (nav.Name == "ExecRegion")
             * {
             *  string erName = nav.GetAttribute("Name", "");
             *
             *  foreach (FileMapping fm in (m_symOrderMap[erName] as SortedList).Values)
             *  {
             *      WriteNextNode(writer, m_symToNavNode[erName + ":" + fm.Name] as XPathNavigator, false);
             *  }
             * }
             */
            else
            {
                XPathNodeIterator children = nav.SelectChildren(XPathNodeType.Element);
                while (children.MoveNext())
                {
                    WriteNextNode(writer, children.Current, iterateSiblings);
                }
            }
            writer.WriteEndElement();

            if (iterateSiblings && nav.MoveToNext())
            {
                WriteNextNode(writer, nav, iterateSiblings);
            }
        }
        public static void RemoveAttribute(this XPathNavigator navigator, string name)
        {
            var navi = navigator.CreateNavigator();

            if (navi.MoveToAttribute(name))
            {
                navi.DeleteSelf();
            }
        }
Beispiel #9
0
        protected virtual Paragraph CreateCodeParagraph(XPathNavigator codeNavigator, Story story, FlowDocumentStyleProvider styleProvider)
        {
            Paragraph paragraph = new Paragraph(new Run());
            // Navigate paragraph using a duplicate navigator. Step inside paragraph's first child before beginning navigation
            XPathNavigator parsingNavigator = codeNavigator.CreateNavigator();

            if (parsingNavigator.NodeType == XPathNodeType.Element && parsingNavigator.Name.ToLower(CultureInfo.InvariantCulture) == "code" && parsingNavigator.MoveToFirstChild())
            {
                ParseContent(parsingNavigator.CreateNavigator(), paragraph.ContentStart, styleProvider);
            }
            MsdnStoryToFlowDocumentConverter.ApplyStyle(paragraph, GetArticleCodeStyle(styleProvider));
            return(paragraph);
        }
Beispiel #10
0
        internal Element(XPathNavigator node)
            : this(node.Name)
        {
            XPathNavigator navigator = node.CreateNavigator();

            if (navigator.MoveToFirstAttribute())
            {
                do
                {
                    AddAttribute(navigator.Name, navigator.Value);
                } while (navigator.MoveToNextAttribute());
            }
        }
Beispiel #11
0
        private static string GetFullPath(XPathNavigator nav)
        {
            nav = nav.CreateNavigator();
            var names = new Stack <string>();

            names.Push(nav.Name);
            while (nav.MoveToParent())
            {
                names.Push(nav.Name);
            }

            return("/" + string.Join("/", names));
        }
        public static void SetOrCreateAttribute(this XPathNavigator navigator, string name, string value)
        {
            var navi = navigator.CreateNavigator();

            if (navi.MoveToAttribute(name))
            {
                navi.SetValue(value);
            }
            else
            {
                navi.CreateAttribute(name, value);
            }
        }
Beispiel #13
0
        public void PopulateDisplayItems()
        {
            XPathNavigator root = UserOptions.OptionsDoc.CreateNavigator();

            root.MoveToFirstChild();
            root = root.SelectSingleNode("results/resultFonts");
            if (root != null)
            {
                XPathNavigator nav = root.CreateNavigator();
                if (nav.MoveToFirstChild())
                {
                    DisplayItem item;
                    string      colorName;

                    itemsBox.Items.Clear();

                    do
                    {
                        item              = new DisplayItem();
                        item.Name         = nav.Name;
                        item.InternalName = nav.LocalName;
                        item.FamilyName   = nav.GetAttribute("family", nav.NamespaceURI);
                        item.Size         = Int32.Parse(nav.GetAttribute("size", nav.NamespaceURI));

                        colorName      = nav.GetAttribute("foreColor", nav.NamespaceURI);
                        item.ForeColor = Color.FromName(colorName);
                        if (!item.ForeColor.IsKnownColor)
                        {
                            item.ForeColor = Color.FromArgb(int.Parse(
                                                                colorName, System.Globalization.NumberStyles.HexNumber));
                        }

                        colorName      = nav.GetAttribute("backColor", nav.NamespaceURI);
                        item.BackColor = Color.FromName(colorName);
                        if (!item.BackColor.IsKnownColor)
                        {
                            item.BackColor = Color.FromArgb(int.Parse(
                                                                colorName, System.Globalization.NumberStyles.HexNumber));
                        }

                        item.FontStyle
                            = (FontStyle)Enum.Parse(
                                  typeof(FontStyle), nav.GetAttribute("style", nav.NamespaceURI));

                        itemsBox.Items.Add(item);
                    }while (nav.MoveToNext());
                }
            }

            itemsBox.SelectedIndex = 0;
        }
Beispiel #14
0
        public string NodePath()
        {
            XPathNavigator n = Node.CreateNavigator();
            string         s = n.Name;

            while (!n.IsSamePosition(Origin.Node) && n.MoveToParent())
            {
                if (!string.IsNullOrEmpty(n.Name))
                {
                    s = n.Name + "." + s;
                }
            }
            return(s);
        }
Beispiel #15
0
        /// <summary>
        /// Creates a body text paragraph from body navigator. Paragraph number is passed in in case different styles
        /// are desired for the first paragraph, etc.
        /// </summary>
        protected override Paragraph CreateBodyTextParagraph(XPathNavigator paragraphNavigator, Story story, FlowDocumentStyleProvider styleProvider, int paragraphNumber)
        {
            Paragraph paragraph = new Paragraph(new Run());

            // Navigate paragraph using a duplicate navigator. Step inside paragraph's first child before beginning navigation
            XPathNavigator parsingNavigator = paragraphNavigator.CreateNavigator();

            if (parsingNavigator.NodeType == XPathNodeType.Element && parsingNavigator.Name.ToLower(CultureInfo.InvariantCulture) == "para" && parsingNavigator.MoveToFirstChild())
            {
                ParseContent(parsingNavigator.CreateNavigator(), paragraph.ContentStart, styleProvider);
            }
            ApplyStyle(paragraph, GetBodyTextParagraphStyle(styleProvider, paragraphNumber));
            return(paragraph);
        }
        private void DeleteDestinationRows()
        {
            XPathNavigator    sas_OrgCountyArea          = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Sec04_PropAreaOfCaverageOrg/my:sas_OrgCountyArea", NamespaceManager);
            XPathNodeIterator OrgCountyAreaCoverageItems = sas_OrgCountyArea.Select("./my:OrgCountyAreaCoverage", NamespaceManager);

            if (OrgCountyAreaCoverageItems.Count > 0)
            {
                for (int i = OrgCountyAreaCoverageItems.Count; i > 0; i--)
                {
                    XPathNavigator OrgCountyAreaCoverageItem = sas_OrgCountyArea.CreateNavigator().SelectSingleNode("my:OrgCountyAreaCoverage[position() = " + i + "]", NamespaceManager);

                    OrgCountyAreaCoverageItem.DeleteSelf();
                }
            }
        }
        /// <summary>
        /// Loads this <see cref="OpmlOutline"/> using the supplied <see cref="XPathNavigator"/> and <see cref="SyndicationResourceLoadSettings"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> used to configure the load operation.</param>
        /// <returns><b>true</b> if the <see cref="OpmlOutline"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="OpmlOutline"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="settings"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source, SyndicationResourceLoadSettings settings)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(source, "source");
            if (source.HasAttributes)
            {
                XPathNavigator attributesNavigator = source.CreateNavigator();
                if (attributesNavigator.MoveToFirstAttribute())
                {
                    if (this.LoadAttribute(attributesNavigator))
                    {
                        wasLoaded = true;
                    }
                    while (attributesNavigator.MoveToNextAttribute())
                    {
                        if (this.LoadAttribute(attributesNavigator))
                        {
                            wasLoaded = true;
                        }
                    }
                }
            }

            if (source.HasChildren)
            {
                XPathNodeIterator outlinesIterator = source.Select("outline");
                if (outlinesIterator != null && outlinesIterator.Count > 0)
                {
                    while (outlinesIterator.MoveNext())
                    {
                        OpmlOutline outline = new OpmlOutline();
                        if (outline.Load(outlinesIterator.Current, settings))
                        {
                            this.Outlines.Add(outline);
                            wasLoaded = true;
                        }
                    }
                }
            }
            SyndicationExtensionAdapter adapter = new SyndicationExtensionAdapter(source, settings);

            adapter.Fill(this);

            return(wasLoaded);
        }
Beispiel #18
0
		public void Read(XPathNavigator navigator, ContentItem item, ReadingJournal journal)
		{
			IDictionary<string, IAttachmentHandler> attachments = explorer.Map<IAttachmentHandler>(item.GetContentType());
			
			foreach(XPathNavigator attachmentElement in EnumerateChildren(navigator))
			{
				string name = attachmentElement.GetAttribute("name", string.Empty);
				if(attachments.ContainsKey(name))
				{
					XPathNavigator attachmentContents = navigator.CreateNavigator();
					attachmentContents.MoveToFirstChild();
					Attachment a = attachments[name].Read(attachmentContents, item);
					if(a != null)
						journal.Report(a);
				}
			}
		}
Beispiel #19
0
        protected virtual void ProcessXml(bool stripResource, bool ignoreResource)
        {
            if (!AllowedAssemblySelector.HasFlag(AllowedAssemblies.AnyAssembly) && _resourceAssembly == null)
            {
                throw new InvalidOperationException("The containing assembly must be specified for XML which is restricted to modifying that assembly only.");
            }

            try {
                XPathNavigator nav = _document.CreateNavigator();

                // Initial structure check - ignore XML document which don't look like linker XML format
                if (!nav.MoveToChild(LinkerElementName, XmlNamespace))
                {
                    return;
                }

                if (_resource != null)
                {
                    if (stripResource)
                    {
                        _context.Annotations.AddResourceToRemove(_resourceAssembly, _resource);
                    }
                    if (ignoreResource)
                    {
                        return;
                    }
                }

                if (!ShouldProcessElement(nav))
                {
                    return;
                }

                ProcessAssemblies(nav.SelectChildren("assembly", ""));

                // For embedded XML, allow not specifying the assembly explicitly in XML.
                if (_resourceAssembly != null)
                {
                    ProcessAssembly(_resourceAssembly, nav, warnOnUnresolvedTypes: true);
                }
            } catch (Exception ex) when(!(ex is LinkerFatalErrorException))
            {
                throw new LinkerFatalErrorException(MessageContainer.CreateErrorMessage($"Error processing '{_xmlDocumentLocation}'", 1013), ex);
            }
        }
Beispiel #20
0
        internal static object ReadArrayProperty(this XPathNavigator reader, string path)
        {
            var comment = reader.CreateNavigator();

            comment.MoveToFirstChild();
            bool isSet  = comment.NodeType == XPathNodeType.Comment && comment.Value == "Set";
            var  childs = reader.SelectChildren(XPathNodeType.Element);
            var  values = new List <object>();

            path += isSet ? "/set" : "/array";
            foreach (XPathNavigator child in childs)
            {
                string childpath = String.Format("{0}[{1}]", path, values.Count);
                object obj       = child.ReadObject(childpath);
                values.Add(obj);
            }
            return(isSet ? (object)new Set(values.ToArray()) : (object)values.ToArray());
        }
Beispiel #21
0
        protected virtual void ProcessXml(bool ignoreResource)
        {
            if (!AllowedAssemblySelector.HasFlag(AllowedAssemblies.AnyAssembly) && _owningModule == null)
            {
                throw new InvalidOperationException("The containing assembly must be specified for XML which is restricted to modifying that assembly only.");
            }

            try
            {
                XPathNavigator nav = _document.CreateNavigator();

                // Initial structure check - ignore XML document which don't look like linker XML format
                if (!nav.MoveToChild(LinkerElementName, XmlNamespace))
                {
                    return;
                }

                if (_owningModule != null)
                {
                    if (ignoreResource)
                    {
                        return;
                    }
                }

                if (!ShouldProcessElement(nav))
                {
                    return;
                }

                ProcessAssemblies(nav);

                // For embedded XML, allow not specifying the assembly explicitly in XML.
                if (_owningModule != null)
                {
                    ProcessAssembly(_owningModule, nav, warnOnUnresolvedTypes: true);
                }
            }
            catch (Exception ex)
            {
                // throw new LinkerFatalErrorException(MessageContainer.CreateErrorMessage(null, DiagnosticId.ErrorProcessingXmlLocation, _xmlDocumentLocation), ex);
                throw ex;
            }
        }
Beispiel #22
0
        public void XPathNavigatorMembers(XPathNavigator nav, IXmlNamespaceResolver nsResolver, XPathExpression pathExpression)
        {
            const string constantPath = "/my/xpath/expression";
            string       path         = "variable path";

            // Should not raise for hard-coded paths
            nav.Compile(constantPath);
            nav.Evaluate("xpath-expression");
            nav.Select(constantPath);
            nav.Matches(FixedPath);

            // Should raise for variable paths
            nav.Compile(path);                              // Noncompliant

            nav.Evaluate(path);                             // Noncompliant
            nav.Evaluate(path, nsResolver);                 // Noncompliant
            nav.Evaluate(pathExpression);                   // Compliant - using path expression objects is ok
            nav.Evaluate(pathExpression, null);

            nav.Matches(path);                              // Noncompliant
            nav.Matches(pathExpression);

            // XPathNavigator selection methods
            nav.Select(path);                               // Noncompliant
            nav.Select(path, nsResolver);                   // Noncompliant
            nav.Select(pathExpression);

            nav.SelectSingleNode(path);                     // Noncompliant
            nav.SelectSingleNode(path, nsResolver);         // Noncompliant
            nav.SelectSingleNode(pathExpression);

            nav.SelectAncestors("name", "uri", false);
            nav.SelectChildren("name", "uri");
            nav.SelectDescendants("name", "uri", false);

            nav.AppendChild("newChild");
            nav.AppendChildElement("prefix", "localName", "uri", "value");
            nav.CheckValidity(null, null);

            var nav2 = nav.CreateNavigator();

            nav2.DeleteRange(nav);
        }
        /// <summary>
        /// Loads this <see cref="OpmlOutline"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="OpmlOutline"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="OpmlOutline"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(source, "source");
            if (source.HasAttributes)
            {
                XPathNavigator attributesNavigator = source.CreateNavigator();
                if (attributesNavigator.MoveToFirstAttribute())
                {
                    if (this.LoadAttribute(attributesNavigator))
                    {
                        wasLoaded = true;
                    }
                    while (attributesNavigator.MoveToNextAttribute())
                    {
                        if (this.LoadAttribute(attributesNavigator))
                        {
                            wasLoaded = true;
                        }
                    }
                }
            }

            if (source.HasChildren)
            {
                XPathNodeIterator outlinesIterator = source.Select("outline");
                if (outlinesIterator != null && outlinesIterator.Count > 0)
                {
                    while (outlinesIterator.MoveNext())
                    {
                        OpmlOutline outline = new OpmlOutline();
                        if (outline.Load(outlinesIterator.Current))
                        {
                            this.Outlines.Add(outline);
                            wasLoaded = true;
                        }
                    }
                }
            }

            return(wasLoaded);
        }
Beispiel #24
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The ReadComponents method reads the components node of the manifest file.
        /// </summary>
        /// -----------------------------------------------------------------------------
        private void ReadComponents(XPathNavigator manifestNav)
        {
            foreach (XPathNavigator componentNav in manifestNav.CreateNavigator().Select("components/component"))
            {
                // Set default order to next value (ie the same as the size of the collection)
                int order = this._componentInstallers.Count;

                string type = componentNav.GetAttribute("type", string.Empty);
                if (this.InstallMode == InstallMode.Install)
                {
                    string installOrder = componentNav.GetAttribute("installOrder", string.Empty);
                    if (!string.IsNullOrEmpty(installOrder))
                    {
                        order = int.Parse(installOrder);
                    }
                }
                else
                {
                    string unInstallOrder = componentNav.GetAttribute("unInstallOrder", string.Empty);
                    if (!string.IsNullOrEmpty(unInstallOrder))
                    {
                        order = int.Parse(unInstallOrder);
                    }
                }

                if (this.Package.InstallerInfo != null)
                {
                    this.Log.AddInfo(Util.DNN_ReadingComponent + " - " + type);
                }

                ComponentInstallerBase installer = InstallerFactory.GetInstaller(componentNav, this.Package);
                if (installer == null)
                {
                    this.Log.AddFailure(Util.EXCEPTION_InstallerCreate);
                }
                else
                {
                    this._componentInstallers.Add(order, installer);
                    this.Package.InstallerInfo.AllowableFiles += ", " + installer.AllowableFiles;
                }
            }
        }
Beispiel #25
0
        static void ParseDelegate(XPathNavigator node)
        {
            SpecDelegate result = new SpecDelegate();

            result.Parameters = new List <SpecField> ();

            XPathNavigator nameNode = node.SelectSingleNode("name");

            result.Name = result.MapName = nameNode.InnerXml;

            GetSpecType(result.Name).TypeObject = result;
            delegateMap.Add(result.Name, result);

            // move to name tag
            var child = node.CreateNavigator();

            child.MoveToFirstChild();
            var returnType = Regex.Match(child.Value, @"typedef (\w*)", RegexOptions.CultureInvariant);

            result.Return          = GetSpecType(returnType.Groups[1].Value);
            result.ReturnIsPointer = Regex.IsMatch(child.Value, @"typedef (\w*)\s*\*", RegexOptions.CultureInvariant);

            foreach (XPathNavigator item in node.Select("type"))
            {
                var paramType = item.Value;

                item.MoveToNext(XPathNodeType.Text);
                var raw = Regex.Match(item.Value, @"\s*(\*)?\s*(\w+)", RegexOptions.CultureInvariant);

                var paramName      = raw.Groups[2].Value;
                var paramIsPointer = raw.Groups[1].Success;

                result.Parameters.Add(new SpecField()
                {
                    Type      = GetSpecType(paramType),
                    Name      = paramName,
                    MapName   = paramName,
                    IsPointer = paramIsPointer,
                });
            }
        }
Beispiel #26
0
        /// <summary>
        /// Updates the node replacing inheritdoc node with comments found.
        /// </summary>
        /// <param name="key">Id of the topic specified</param>
        /// <param name="inheritDocNodeNavigator">Navigator for inheritdoc node</param>
        /// <param name="contentNodeNavigator">Navigator for content</param>
        private void UpdateNode(string key, XPathNavigator inheritDocNodeNavigator, XPathNavigator contentNodeNavigator)
        {
            // retrieve the selection filter if specified.
            string selectValue = inheritDocNodeNavigator.GetAttribute("select", string.Empty);

            if (!String.IsNullOrWhiteSpace(selectValue))
            {
                this.ParentBuildComponent.WriteMessage(key, MessageLevel.Warn, "The inheritdoc 'select' " +
                                                       "attribute has been deprecated.  Use the equivalent 'path' attribute instead.");
            }
            else
            {
                selectValue = inheritDocNodeNavigator.GetAttribute("path", string.Empty);
            }

            if (!String.IsNullOrWhiteSpace(selectValue))
            {
                sourceExpression = XPathExpression.Compile(selectValue);
            }

            inheritDocNodeNavigator.MoveToParent();

            if (inheritDocNodeNavigator.LocalName != "comments" && inheritDocNodeNavigator.LocalName != "element")
            {
                sourceExpression = XPathExpression.Compile(inheritDocNodeNavigator.LocalName);
            }
            else
            {
                inheritDocNodeNavigator.MoveTo(this.sourceDocument.CreateNavigator().SelectSingleNode(inheritDocExpression));
            }

            XPathNodeIterator sources = (XPathNodeIterator)contentNodeNavigator.CreateNavigator().Evaluate(sourceExpression);

            inheritDocNodeNavigator.DeleteSelf();

            // append the source nodes to the target node
            foreach (XPathNavigator source in sources)
            {
                inheritDocNodeNavigator.AppendChild(source);
            }
        }
Beispiel #27
0
        public IList <string> GrabBackDropUrls(XPathNavigator nav)
        {
            List <string>     urls  = new List <string>();
            XPathNodeIterator nIter = nav.SelectChildren("backdrop", "");

            if (nav.MoveToFollowing("backdrop", ""))
            {
                XPathNavigator localNav = nav.CreateNavigator();
                nav.MoveToParent();
                for (int i = 0; i < nIter.Count; i++)
                {
                    if (localNav.GetAttribute("size", "").ToUpperInvariant().Equals("original".ToUpperInvariant()))
                    {
                        urls.Add(localNav.Value);
                    }

                    localNav.MoveToNext();
                }
            }
            return(urls);
        }
        private static void WriteElement(TextWriter writer, XPathNavigator nav, int depth, string leadIn)
        {
            writer.Write(leadIn);
            writer.WriteLine(nav.Name);

            WriteNamespaces(writer, nav, leadIn);

            if (nav.HasAttributes)
            {
                WriteAttributes(writer, nav, leadIn);
            }

            if (!nav.HasChildren)
            {
                return;
            }

            var childNav = nav.CreateNavigator();

            childNav.MoveToFirstChild();
            Traverse(writer, childNav, depth + 1);
        }
Beispiel #29
0
		public void PopulateDisplayItems ()
		{
			XPathNavigator root = UserOptions.OptionsDoc.CreateNavigator();
			root.MoveToFirstChild();
			root = root.SelectSingleNode("editor/editorFonts/lexStyles");
			if (root != null)
			{
				XPathNavigator nav = root.CreateNavigator();
				DisplayItem item;
				string colorName;

				foreach (LexStyleItem lexItem in LexStyleItems.Items)
				{
					if ((nav = nav.SelectSingleNode(lexItem.InternalName)) != null)
					{
						item = new DisplayItem(lexItem);

						colorName = nav.GetAttribute("foreColor", nav.NamespaceURI);
						item.ForeColor = Color.FromName(colorName);

						colorName = nav.GetAttribute("backColor", nav.NamespaceURI);
						item.BackColor = Color.FromName(colorName);

						item.FontStyle
							= (FontStyle)Enum.Parse(
							typeof(FontStyle), nav.GetAttribute("style", nav.NamespaceURI));

						itemsBox.Items.Add(item);
						Logger.WriteLine("Populate (" + item.Name + ", " + item.ForeColor + ", " + item.BackColor + ")");
					}

					nav = root;
				}
				while (nav.MoveToNext()) ;
			}

			itemsBox.SelectedIndex = 0;
		}
        private void WriteMultilineValue(XPathNavigator nav)
        {
            string type      = null;
            var    props     = nav.CreateNavigator();
            var    keepGoing = true;

            while (keepGoing)
            {
                props.MoveToParent();
                if (props.MoveToFirstAttribute())
                {
                    keepGoing = false;
                }
            }
            keepGoing = true;
            while (keepGoing)
            {
                if (props.Name == "type")
                {
                    type = props.Value;
                }
                if (!(props.MoveToNextAttribute()))
                {
                    keepGoing = false;
                }
            }
            if (string.IsNullOrEmpty(type))
            {
                WriteJsonValue(nav);
            }
            else
            {
                props.MoveToRoot();
                props.MoveToFirstChild();
                WriteJsonValue(nav);
            }
        }