Exemple #1
0
        /// <inheritdoc />
        public override InspectableField FindPath(string path)
        {
            string subPath = GetSubPath(path, depth + 1);

            if (string.IsNullOrEmpty(subPath))
            {
                return(null);
            }

            int  lastLeftIdx  = subPath.LastIndexOf("Key[");
            int  lastRightIdx = -1;
            bool isKey;

            if (lastLeftIdx != -1)
            {
                lastRightIdx = subPath.LastIndexOf(']', lastLeftIdx);
                isKey        = true;
            }
            else
            {
                lastLeftIdx  = subPath.LastIndexOf("Value[");
                lastRightIdx = subPath.LastIndexOf(']', lastLeftIdx);

                isKey = false;
            }

            if (lastLeftIdx == -1 || lastRightIdx == -1)
            {
                return(null);
            }

            int count = lastRightIdx - 1 - lastLeftIdx;

            if (count <= 0)
            {
                return(null);
            }

            string arrayIdxStr = subPath.Substring(lastLeftIdx, count);

            if (!int.TryParse(arrayIdxStr, out int idx))
            {
                return(null);
            }
            ;

            if (idx >= dictionaryGUIField.NumRows)
            {
                return(null);
            }

            InspectableDictionaryGUIRow row   = dictionaryGUIField.GetRow(idx);
            InspectableField            field = null;

            if (isKey)
            {
                field = row?.FieldKey;
            }
            else
            {
                field = row?.FieldValue;
            }

            if (field != null)
            {
                if (field.Path == path)
                {
                    return(field);
                }

                return(field.FindPath(path));
            }

            return(null);
        }