示例#1
0
        internal void MergeKey(CKey inKey)
        {
            AddComments(inKey.Comments);

            TakeAllValues(inKey, false);

            List <CKey> keys = new List <CKey>(inKey._keys);

            for (int i = 0; i < keys.Count; i++)
            {
                var in_sub_key = keys[i];

                CKey child_key = null;

                if (!in_sub_key.IsArray)
                {
                    child_key = FindChildKey(in_sub_key.Name);
                }

                if (child_key != null)
                {
                    child_key.MergeKey(in_sub_key);
                }
                else
                {
                    in_sub_key.SetParent(this);
                }
            }
        }
示例#2
0
        static void OnClosingKey(CKey key, EKeyAddingMode inKeyAddMode, ITreeBuildSupport inSupport)
        {
            if (key == null)
            {
                return;
            }

            if (key.IsEmpty)
            {
                inSupport.GetLogger().LogError(EErrorCode.HeadWithoutValues, key);
                return;
            }

            if (inKeyAddMode == EKeyAddingMode.AddUnique)
            {
                return;
            }

            CKey parent = key.Parent;

            if (parent == null)
            {
                inSupport.GetLogger().LogError(EErrorCode.KeyMustHaveParent, key);
                return;
            }

            key.SetParent(null);

            if (inKeyAddMode == EKeyAddingMode.Override)
            {
                var pathes = new List <List <string> >();
                key.GetTerminalPathes(pathes, new List <string>());

                //for correct deleting array elems
                for (int i = pathes.Count - 1; i >= 0; --i)
                {
                    var path = pathes[i];
                    RemoveKeysByPath(parent, path);
                }

                inKeyAddMode = EKeyAddingMode.Add;
            }

            if (inKeyAddMode == EKeyAddingMode.Add)
            {
                CKey child_key = parent.FindChildKey(key.Name);
                if (child_key != null)
                {
                    child_key.MergeKey(key);
                }
                else
                {
                    key.SetParent(parent);
                }
            }
        }