コード例 #1
0
        static void ExecuteCommand_Delete(CKey inParent, CTokenLine line, ITreeBuildSupport inSupport)
        {
            if (line.CommandParams.Length == 0 || string.IsNullOrEmpty(line.CommandParams[0]))
            {
                inSupport.GetLogger().LogError(EErrorCode.PathEmpty, line);
                return;
            }

            string key_path = line.CommandParams[0];

            CKey start_key = inParent;
            int  i         = 0;

            while (i < key_path.Length && key_path[i] == '<' && start_key.Parent != null)
            {
                start_key = start_key.Parent;
                i++;
            }
            key_path = key_path.Substring(i);

            string[] path = key_path.Split(new char[] { '\\', '/' });

            if (!RemoveKeysByPath(start_key, path))
            {
                inSupport.GetLogger().LogError(EErrorCode.CantFindKey, line, $"Start key: {inParent.GetPath()}");
            }
        }