ExtensionDeclarationXml ReadDeclaration()
        {
            if (_declarationNode == null || _declarationNode.NodeType != XmlNodeType.Element || !_declarationNode.HasChildNodes)
            {
                return(null);
            }

            var declaration = new ExtensionDeclarationXml();

            for (int i = 0; i < _declarationNode.ChildNodes.Count; i++)
            {
                var node = _declarationNode.ChildNodes[i];
                if (node.NodeType != XmlNodeType.Element || node.Attributes == null || node.Attributes.Count == 0)
                {
                    continue;                                                             // not a valid definition
                }
                var epTypeName = XmlHelper.GetMatchingAttribueValue(node, AttributeType); //Get the extension point type
                if (!string.IsNullOrEmpty(epTypeName))                                    //'Type' attribute defined: this is a valid extension point
                {
                    // This is an extension point that defined in this addin
                    var epId = XmlHelper.GetNodeName(node);
                    var ep   = new ExtensionPointXml
                    {
                        Id          = epId,
                        TypeName    = epTypeName,
                        Description = XmlHelper.GetMatchingAttribueValue(node, AttributeDescription)
                    };

                    declaration.AddExtensionPoint(ep);

                    if (node.HasChildNodes)
                    {
                        for (int j = 0; j < node.ChildNodes.Count; j++)
                        {
                            var eb = ReadExtensionBuilder(node.ChildNodes[j], epId, epId);
                            if (eb != null)
                            {
                                ep.AddChild(eb);
                            }
                        }
                    }
                }
                else
                {
                    // This might be an extension point that defined in another addin
                    var ebGroupPath = XmlHelper.GetMatchingAttribueValue(node, AttributePath);
                    if (ebGroupPath == null) // not a valid definition
                    {
                        continue;
                    }
                    var ebGroup = ReadExtensionBuilderGroup(node, ebGroupPath);
                    if (ebGroup != null)
                    {
                        declaration.AddExtensionBuilderGroup(ebGroup);
                    }
                }
            }

            return(declaration);
        }
        ExtensionSchemaXml ReadExtensionSchema()
        {
            if (_extensionSchemaNode == null || _extensionSchemaNode.NodeType != XmlNodeType.Element || !_extensionSchemaNode.HasChildNodes)
            {
                return(null);
            }

            var schema = new ExtensionSchemaXml();

            for (int i = 0; i < _extensionSchemaNode.ChildNodes.Count; i++)
            {
                var node = _extensionSchemaNode.ChildNodes[i];
                if (node.NodeType != XmlNodeType.Element || node.Attributes == null || node.Attributes.Count == 0)
                {
                    continue;                                                             // not a valid definition
                }
                var epTypeName = XmlHelper.GetMatchingAttribueValue(node, AttributeType); //Get the extension point type
                if (!string.IsNullOrEmpty(epTypeName))                                    //'Type' attribute defined: this is a valid extension point
                {
                    // This is an extension point that defined in this addin
                    var epName = XmlHelper.GetNodeName(node);
                    var ep     = new ExtensionPointXml
                    {
                        Name        = epName,
                        TypeName    = epTypeName,
                        Description = XmlHelper.GetMatchingAttribueValue(node, AttributeDescription)
                    };

                    schema.AddExtensionPoint(ep);

                    if (node.HasChildNodes)
                    {
                        for (int j = 0; j < node.ChildNodes.Count; j++)
                        {
                            var eb = ReadExtensionBuilder(node.ChildNodes[j], epName, epName);
                            if (eb != null)
                            {
                                ep.AddChild(eb);
                            }
                        }
                    }
                }
                else
                {
                    // This might be an extension point that defined in another addin
                    var ebGroupPath = XmlHelper.GetMatchingAttribueValue(node, AttributePath);
                    ebGroupPath = ExtensionHelper.NormalizePath(ebGroupPath);
                    if (ebGroupPath == null) // not a valid definition
                    {
                        continue;
                    }

                    var ebGroup = ReadExtensionBuilderGroup(node, ebGroupPath);
                    if (ebGroup != null)
                    {
                        schema.AddExtensionBuilderGroup(ebGroup);
                    }
                }
            }

            return(schema.ExtensionBuilderGroups == null && schema.ExtensionPoints == null ? null : schema);
        }