Beispiel #1
0
        /// <summary>
        /// Completely replaces this node with another node tree, positioning the new tree in the place of local node.
        /// Existing node is deleted after this operation completes, in its place child nodes from other node are inserted
        /// preserving their existing order. Attributes of other node get merged into parent of existing node
        /// </summary>
        public void Include(ConfigSectionNode existing, ConfigSectionNode other)
        {
            if (!Root.Exists)
            {
                return;
            }

            if (IsReadOnly)
            {
                throw new ConfigException(StringConsts.CONFIGURATION_READONLY_ERROR);
            }

            if (existing == null || other == null)
            {
                throw new ConfigException(StringConsts.ARGUMENT_ERROR + "Configuration.Include(null|null)");
            }

            if (existing.Configuration != this)
            {
                throw new ConfigException(StringConsts.CONFIGURATION_NODE_DOES_NOT_BELONG_TO_THIS_CONFIGURATION_ERROR.Args(existing.RootPath));
            }

            if (other.Configuration == this)
            {
                throw new ConfigException(StringConsts.CONFIGURATION_NODE_MUST_NOT_BELONG_TO_THIS_CONFIGURATION_ERROR.Args(other.RootPath));
            }

            if (existing == Root)
            {
                throw new ConfigException(StringConsts.CONFIGURATION_CAN_NOT_INCLUDE_INSTEAD_OF_ROOT_ERROR.Args(other.RootPath));
            }

            existing.include(other);
        }