Example #1
0
        public RelDocNodeProxy(Main.IDocumentLeafNode docNode, Main.IDocumentNode parentNode)
        {
            if (null == docNode)
            {
                throw new ArgumentNullException(nameof(docNode));
            }
            if (null == parentNode)
            {
                throw new ArgumentNullException(nameof(parentNode));
            }
            var docNodeRoot    = Main.AbsoluteDocumentPath.GetRootNode(docNode);
            var parentNodeRoot = Main.AbsoluteDocumentPath.GetRootNode(parentNode);

            if (!object.ReferenceEquals(docNodeRoot, parentNodeRoot))
            {
                throw new ArgumentException(string.Format("parentNode (type: {0}) and docNode (type: {1}) have no common root. This suggests that one of the items is not rooted. Please report this error! The type of the parent node's root is {2}. The type of the docNode's root is {3}.", parentNode.GetType(), docNode.GetType(), parentNodeRoot.GetType(), docNodeRoot.GetType()));
            }

            InternalSetDocNode(docNode, parentNode);

            if (!(_docNodePath != null))
            {
                throw new InvalidProgramException(); // because we tested above that both nodes have a common root
            }
            _parent = parentNode;
        }