Exemplo n.º 1
0
 public void Del(string path)
 {
     if (!validPath(path))
     {
         throw new Exception("Illegal path");
     }
     CSOCore.Delete(content, path, sep);
 }
Exemplo n.º 2
0
        public void Update(string path, JValue value)
        {
            if (!validPath(path))
            {
                throw new Exception("Illegal path");
            }

            if (value is JContainer jc)
            {
                CSOCore.Update(ref content, path, sep, (jc).content);
            }
            else
            {
                CSOCore.Update(ref content, path, sep, value);
            }
        }
Exemplo n.º 3
0
 public void RecursiveIterate(Action <string, JValue> callback)
 {
     CSOCore.Iterate("", (Container)content, (path, node) =>
     {
         if (node is StringContainer sc)
         {
             callback(path, JObject.CreateFromRef(sc));
         }
         else if (node is ArrayContainer ac)
         {
             callback(path, JArray.CreateFromRef(ac));
         }
         else
         {
             callback(path, (JValue)node);
         }
     });
 }
Exemplo n.º 4
0
        public JValue QueryCopy(string path, out string foundPath)
        {
            object cpy = CSOCore.QueryRef(content, path, out foundPath, sep).DeepClone();

            if (cpy is JLeaf jl)
            {
                return(jl);
            }
            else
            {
                if (cpy is StringContainer sc)
                {
                    return(JObject.CreateFromRef(sc));
                }
                else
                {
                    return(JArray.CreateFromRef((ArrayContainer)cpy));
                }
            }
        }
Exemplo n.º 5
0
        public JValue Query(string path, out string foundPath)
        {
            if (!validPath(path))
            {
                throw new Exception("Illegal path");
            }
            object ptr = CSOCore.QueryRef(content, path, out foundPath, sep);

            if (ptr is JLeaf jl)
            {
                return(jl);
            }
            else
            {
                if (ptr is StringContainer sc)
                {
                    return(JObject.CreateFromRef(sc));
                }
                else
                {
                    return(JArray.CreateFromRef((ArrayContainer)ptr));
                }
            }
        }
Exemplo n.º 6
0
 public void CopyOnUpdate(string path, JValue value) => CSOCore.Update(ref content, path, sep, value.DeepClone());
Exemplo n.º 7
0
 public bool Exists(string path) => CSOCore.Exists((Container)content, path, sep);