Exemplo n.º 1
0
        public static void Iterate(string path, Container mref, Action <string, Object> callback)
        {
            foreach (object kvp in mref)
            {
                object  key;
                CSOPath _path = new CSOPath(path);

                if (mref is StringContainer)
                {
                    key    = ((KeyValuePair <string, object>)kvp).Key;
                    _path += (StringKey)(string)key;
                }
                else
                {
                    key = ((KeyValuePair <int, object>)kvp).Key;

                    if (mref is ArrayContainer)
                    {
                        _path += (ArrayKey)(int)key;
                    }
                    else
                    {
                        _path += (NumericKey)(int)key;
                    }
                }

                Object value = mref[key];

                if (value is Container)
                {
                    Iterate(_path.ToPathString(), (Container)value, callback);
                }
                else
                {
                    callback(_path.ToPathString(), value);
                }
            }

            if (mref.Count == 0)
            {
                callback(path, mref);
            }
        }
Exemplo n.º 2
0
 public string ToComponent(bool forceBoxing) => CSOPath.escapePath_Sep(boxingRequired || forceBoxing ? "{" + key + "}" : key, path_sep);
Exemplo n.º 3
0
 public static ref Object QueryAlias(ref Object mptr, string vctr, Action <string> callback, string path_sep)
 {
     CSOPath    foundPath = new CSOPath();
     ref Object o         = ref QueryAlias(ref mptr, new CSOPath(vctr, path_sep), (fp) => foundPath = fp);