/// <summary> /// copy constructor. /// </summary> /// <param name="other">navigator to be copied</param> public XPathObjectNavigator(XPathObjectNavigator other) { _context = other._context; _state = other._state; _root = other._root; _lang = other._lang; }
/// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.IsSamePosition" /> for details. /// </summary> public override bool IsSamePosition(System.Xml.XPath.XPathNavigator other) { Trace("IsSamePosition"); XPathObjectNavigator x = other as XPathObjectNavigator; if (null == x) { return(false); } return(_state.IsSamePosition(x._state)); }
/// <summary> /// See <see cref="System.Xml.XPath.XPathNavigator.MoveTo" /> for details. /// </summary> public override bool MoveTo(System.Xml.XPath.XPathNavigator other) { Trace("MoveTo"); XPathObjectNavigator navigator = other as XPathObjectNavigator; if (null == other) { return(false); } _state = navigator._state; _root = navigator._root; _context = navigator._context; return(true); }
/// <summary> /// copy constructor. /// </summary> /// <param name="other">navigator to be copied</param> public XPathObjectNavigator(XPathObjectNavigator other) { _context = other._context; _state = other._state; _root = other._root; _lang = other._lang; }
public void TestSelectByField() { Customer customer1 = new Customer("Rodrigo", "Oliveira", new Address("al. Calder�o Branco", 45)); customer1.Email = "*****@*****.**"; XPathObjectNavigator navigator = new XPathObjectNavigator(customer1); AssertSame(customer1.Email, navigator.SelectObject("Email")); AssertSame(customer1, navigator.SelectObject("/Customer[Email='*****@*****.**']")); }
public void TestSelectObjects() { Address address = new Address("Strawberry Street", 45); Customer customer1 = new Customer("Rodrigo", "Oliveira", address); Customer customer2 = new Customer("Marcia", "Longo", address); Customer[] customers = { customer1, customer2 }; XPathObjectNavigator navigator = new XPathObjectNavigator(customers); object[] actual = navigator.SelectObjects("Customer[Address/Number = 45]"); AssertEquals(2, actual.Length); AssertEquals(customer1, actual[0]); AssertEquals(customer2, actual[1]); }
public void TestIDictionaryProperties() { Customer customer = new Customer("Rodrigo", "Oliveira", new Address("Penny Lane", 64)); customer.Properties["email"] = "*****@*****.**"; XPathObjectNavigator navigator = new XPathObjectNavigator(customer); AssertEquals(customer.Properties["email"], navigator.SelectObject("Properties/email")); }
public void TestIListProperties() { Product p1 = new Product("egg"); Product p2 = new Product("Monty Python Flying Circus Box"); p2.Categories.Add("Silly Stuff"); Customer c1 = new Customer("Rodrigo", "Oliveira", new Address("Al. Ribeir�o Preto", 487)); Customer c2 = new Customer("Marcia", "Longo", new Address("Al. Ribeir�o Preto", 487)); Order o1 = new Order(c1); o1.Add(new OrderItem(p1, 10)); o1.Add(new OrderItem(p2, 1)); Order o2 = new Order(c2); o2.Add(new OrderItem(p1, 15)); o2.Add(new OrderItem(p2, 1)); Order[] orders = new Order[] { o1, o2 }; XPathObjectNavigator navigator = new XPathObjectNavigator(orders, "Orders"); AssertEquals(2, navigator.Select("//Order").Count); AssertEquals(2, navigator.Select("Order").Count); AssertEquals(o1, navigator.SelectObject("Order[1]")); AssertEquals(o2, navigator.SelectObject("Order[2]")); AssertEquals(o1, navigator.SelectObject("//Order[Customer/FirstName='Rodrigo']")); AssertEquals(o2, navigator.SelectObject("//Order[Customer/LastName='Longo']")); XPathNodeIterator i = navigator.Select("//Product[Name='egg']"); AssertEquals(2, i.Count); AssertEquals(true, i.MoveNext()); AssertEquals(p1, ((XPathObjectNavigator)i.Current).Node); AssertEquals(o2.Items[0], navigator.SelectObject("//OrderItem[Quantity>10]")); AssertEquals(p2, navigator.SelectObject("//Product[Categories/String='Silly Stuff']")); }
public void TestSimpleProperties() { Address address = new Address("Al. Calder�o Branco", 784); Customer customer = new Customer("Rodrigo", "Oliveira", address); XPathObjectNavigator context = new XPathObjectNavigator(customer); XPathNodeIterator i = context.Select("/Customer/Address/Street"); AssertEquals(1, i.Count); AssertEquals(true, i.MoveNext()); AssertEquals(customer.Address.Street, i.Current.Value); AssertEquals(customer.Address.Street, ((XPathObjectNavigator)i.Current).Node); i = context.Select("FirstName"); AssertEquals(1, i.Count); AssertEquals(true, i.MoveNext()); AssertEquals(customer.FirstName, i.Current.Value); i = context.Select("/Customer/LastName"); AssertEquals(true, i.MoveNext()); AssertEquals(customer.LastName, i.Current.Value); }