Exemplo n.º 1
0
 internal override void ReplaceChild(ConfigNode n, KeyType key)
 {
     if (!(key is StringKey))
     {
         throw new ArgumentException("Replacing node on Object asks for a string key.");
     }
     string k = key.RawValue();
     if (_children.ContainsKey(k))
     {
         if (_children[k].NodeType == ConfigNodeType.LEAF && n.NodeType == ConfigNodeType.LEAF)
         {
             var node = _children[k] as ConfigLeafNode;
             if (node != null)
             {
                 if (node.IsEncrypted)
                 {
                     node.ReplaceEncryptedContent(((ConfigLeafNode)n).RawValue);
                 }
                 else
                 {
                     node.RawValue = ((ConfigLeafNode)n).RawValue;
                 }
             }
         }
         else
         {
             _children[k] = n;
             n.IsSelected = true;
             n.SavePropertyChangeHandler(_currentChangedHandler); //wire handlers to new nodes
             OnPropertyChanged("Children");
             PropagateChange(new ReplaceChangeEventArgs(KeyLabel, n.KeyLabel));
         }
     }
     else
     {
         throw new KeyNotFoundException("No child with key " + key + " is found in " + KeyLabel);
     }
 }