Exemplo n.º 1
0
        private NodeFragment RunImpl(Options options)
        {
            INode root = null;
            var   declarationAttributes = NodeAttributeCollection.Empty;
            var   settings = new XmlReaderSettings()
            {
                IgnoreComments   = ((options & Options.IgnoreComments) != 0),
                IgnoreWhitespace = true
            };

            using (var reader = XmlReader.Create(new StringReader(xml), settings))
            {
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        var rootBuilder = ParseElement(0, reader);
                        root = rootBuilder(1);
                        break;

                    case XmlNodeType.XmlDeclaration:
                        declarationAttributes = new NodeAttributeCollection(GetAttributes(reader));
                        break;

                    default:
                        break;
                    }
                }
            }

            if (root == null)
            {
                throw new ArgumentException("The specified XML fragment does not have any root element.", "xml");
            }

            return(new NodeFragment(new NodeDeclaration(declarationAttributes), root));
        }
Exemplo n.º 2
0
 /// <inheritdoc />
 public DiffSet Diff(NodeAttributeCollection expected, IXmlPathStrict path, IXmlPathStrict pathExpected, Options options)
 {
     return(DiffEngineFactory.ForAttributes(expected, this, path, pathExpected, options).Diff());
 }