Esempio n. 1
0
        public void TestParse()
        {
            JsonPath path = new JsonPath(JsonPath.Root + "['foo']['bar'][0]");

            Assert.AreEqual(JsonPath.Root, path.Top);
            path = path.ChildReference();
            Assert.AreEqual("foo", path.Top);
            path = path.ChildReference();
            Assert.AreEqual("bar", path.Top);
            path = path.ChildReference();
            Assert.AreEqual(0, path.TopAsInt);
        }
Esempio n. 2
0
 public void VisitComplexBase(ComplexExpressionBase expression)
 {
     if (_refID.Top == JsonPath.Root)
     {
         if (expression.Parent != null)
         {
             throw new ArgumentException("Reference for this passed to object that is not at the root", "refID");
         }
     }
     else
     {
         // have to assume that the parent checked that we were the right reference
         // should only get here if we have a parent, if no parent we're not valid
         if (expression.Parent == null)
         {
             throw new ArgumentException("Invalid reference", "refID");
         }
     }
     // it is this object, check if we need to go further
     _refID = _refID.ChildReference();
     if (_refID.IsEmpty)
     {
         _expr = expression;
     }
 }
Esempio n. 3
0
        public void TestImmutableChild()
        {
            JsonPath path = new JsonPath(JsonPath.Root);

            path = path.Append("foo");
            JsonPath path2 = path.ChildReference();

            Assert.AreNotSame(path, path2);
        }