public virtual void OnContextChanged()
        {
            this._checker = null;

            // Get intellisense for elements and attributes
            if (this._node.NodeType == XmlNodeType.Element ||
                this._node.NodeType == XmlNodeType.Attribute ||
                this._node.NodeType == XmlNodeType.Text ||
                this._node.NodeType == XmlNodeType.CDATA)
            {
                IXmlTreeNode elementNode = GetClosestElement(this._node);
                if (elementNode != null && elementNode.NodeType == XmlNodeType.Element)
                {
                    this._xn = elementNode.Node;
                    if (_xn is XmlElement)
                    {
                        this._checker = new Checker((XmlElement)_xn,
                                                    elementNode == this._node.ParentNode ? IntellisensePosition.FirstChild :
                                                    (this._node.Node == null ? IntellisensePosition.AfterNode : IntellisensePosition.OnNode)
                                                    );
                        this._checker.ValidateContext(_model);
                    }
                }
            }
        }
        static IXmlTreeNode GetClosestElement(IXmlTreeNode treeNode)
        {
            IXmlTreeNode element = treeNode.ParentNode;

            if (treeNode.ParentNode != null)
            {
                foreach (IXmlTreeNode child in treeNode.ParentNode.Nodes)
                {
                    if (child.Node != null && child.NodeType == XmlNodeType.Element)
                    {
                        element = child;
                    }
                    if (child == treeNode)
                    {
                        break;
                    }
                }
            }
            return(element);
        }
        XmlSchemaInfo GetSchemaInfo()
        {
            IXmlTreeNode tn = _node;

            if (tn.NodeType == XmlNodeType.Text ||
                tn.NodeType == XmlNodeType.CDATA)
            {
                tn = tn.ParentNode;
            }
            if (tn == null)
            {
                return(null);
            }
            XmlNode xn = tn.Node;

            if (xn != null && _model != null)
            {
                XmlSchemaInfo info = _model.GetTypeInfo(xn);
                return(info);
            }
            return(null);
        }
 public void SetContextNode(IXmlTreeNode node)
 {
     this.ContextNode = node;
     OnContextChanged();
 }