Exemplo n.º 1
0
        public void singleAttribute()
        {
            XPathContext ctx = new XPathContext();

            ctx.SetChildren(Linqy.Singleton(new Element("foo")));
            ctx.NavigateToChild(0);
            ctx.AddAttribute(new XmlQualifiedName("bar"));
            ctx.NavigateToAttribute(new XmlQualifiedName("bar"));
            Assert.AreEqual("/foo[1]/@bar", ctx.XPath);
            Assert.AreEqual("/foo[1]", ctx.ParentXPath);
        }
Exemplo n.º 2
0
    static void Main(string[] args)
    {
        var inputs = new Dictionary <int, string>()
        {
            { 2, "second" },
            { 3, "Fizz" },
            { 5, "Buzz" },
            { 6, "Sixth" }
        };

        Console.WriteLine("Vanilla:");
        Console.WriteLine();
        Vanilla.FizzBuzz(inputs, Console.Out);
        Console.WriteLine();

        Console.WriteLine("Linq-y:");
        Console.WriteLine();
        Linqy.FizzBuzz(inputs, Console.Out);

        Console.ReadLine();
    }
Exemplo n.º 3
0
        public void AttributesAndNs()
        {
            Dictionary <string, string> m = new Dictionary <string, string>();

            m["bar"] = "urn:foo:bar";
            XPathContext ctx = new XPathContext(m);

            ctx.SetChildren(Linqy.Singleton(new Element("foo",
                                                        "urn:foo:bar")));
            ctx.NavigateToChild(0);
            List <XmlQualifiedName> l = new List <XmlQualifiedName>();

            l.Add(new XmlQualifiedName("baz"));
            l.Add(new XmlQualifiedName("baz", "urn:foo:bar"));
            ctx.AddAttributes(l);
            ctx.NavigateToAttribute(new XmlQualifiedName("baz"));
            Assert.AreEqual("/bar:foo[1]/@baz", ctx.XPath);
            Assert.AreEqual("/bar:foo[1]", ctx.ParentXPath);
            ctx.NavigateToParent();
            ctx.NavigateToAttribute(new XmlQualifiedName("baz", "urn:foo:bar"));
            Assert.AreEqual("/bar:foo[1]/@bar:baz", ctx.XPath);
            Assert.AreEqual("/bar:foo[1]", ctx.ParentXPath);
            ctx.NavigateToParent();
        }