コード例 #1
0
ファイル: Extension.cs プロジェクト: mjakeman/Hyena.Addins
        void VerifyNode(string location, ExtensionNodeDescription node, StringCollection errors)
        {
            string id = node.GetAttribute("id");

            if (id.Length > 0)
            {
                id = "(" + id + ")";
            }
            if (node.NodeName == "Condition" && node.GetAttribute("id").Length == 0)
            {
                errors.Add(location + node.NodeName + id + ": Missing 'id' attribute in Condition element.");
            }
            if (node.NodeName == "ComplexCondition")
            {
                if (node.ChildNodes.Count > 0)
                {
                    VerifyConditionNode(location, node.ChildNodes[0], errors);
                    for (int n = 1; n < node.ChildNodes.Count; n++)
                    {
                        VerifyNode(location + node.NodeName + id + "/", node.ChildNodes[n], errors);
                    }
                }
                else
                {
                    errors.Add(location + "ComplexCondition: Missing child condition in ComplexCondition element.");
                }
            }
            foreach (ExtensionNodeDescription cnode in node.ChildNodes)
            {
                VerifyNode(location + node.NodeName + id + "/", cnode, errors);
            }
        }
コード例 #2
0
 /// <summary>
 /// Gets the type of the node.
 /// </summary>
 /// <returns>
 /// The node type.
 /// </returns>
 /// <remarks>
 /// This method only works when the add-in description to which the node belongs has been
 /// loaded from an add-in registry.
 /// </remarks>
 public ExtensionNodeType GetNodeType()
 {
     if (Parent is Extension)
     {
         Extension ext = (Extension)Parent;
         object    ob  = ext.GetExtendedObject();
         if (ob is ExtensionPoint)
         {
             ExtensionPoint ep = (ExtensionPoint)ob;
             return(ep.NodeSet.GetAllowedNodeTypes() [NodeName]);
         }
         else if (ob is ExtensionNodeDescription)
         {
             ExtensionNodeDescription pn = (ExtensionNodeDescription)ob;
             ExtensionNodeType        pt = ((ExtensionNodeDescription)pn).GetNodeType();
             if (pt != null)
             {
                 return(pt.GetAllowedNodeTypes() [NodeName]);
             }
         }
     }
     else if (Parent is ExtensionNodeDescription)
     {
         ExtensionNodeType pt = ((ExtensionNodeDescription)Parent).GetNodeType();
         if (pt != null)
         {
             return(pt.GetAllowedNodeTypes() [NodeName]);
         }
     }
     return(null);
 }
コード例 #3
0
        /// <summary>
        /// Adds an extension node to the module.
        /// </summary>
        /// <returns>
        /// The extension node.
        /// </returns>
        /// <param name='path'>
        /// Path that identifies the extension point.
        /// </param>
        /// <param name='nodeName'>
        /// Node name.
        /// </param>
        /// <remarks>
        /// This method creates a new Extension object for the provided path if none exist.
        /// </remarks>
        public ExtensionNodeDescription AddExtensionNode(string path, string nodeName)
        {
            ExtensionNodeDescription node = new ExtensionNodeDescription(nodeName);

            GetExtension(path).ExtensionNodes.Add(node);
            return(node);
        }
コード例 #4
0
ファイル: Extension.cs プロジェクト: mjakeman/Hyena.Addins
        void VerifyConditionNode(string location, ExtensionNodeDescription node, StringCollection errors)
        {
            string nodeName = node.NodeName;

            if (nodeName != "Or" && nodeName != "And" && nodeName != "Not" && nodeName != "Condition")
            {
                errors.Add(location + "ComplexCondition: Invalid condition element: " + nodeName);
                return;
            }
            foreach (ExtensionNodeDescription cnode in node.ChildNodes)
            {
                VerifyConditionNode(location, cnode, errors);
            }
        }
コード例 #5
0
 /// <summary>
 /// Gets the extension path under which this node is registered
 /// </summary>
 /// <returns>
 /// The parent path.
 /// </returns>
 /// <remarks>
 /// For example, if the id of the node is 'ThisNode', and the node is a child of another node with id 'ParentNode', and
 /// that parent node is defined in an extension with the path '/Core/MainExtension', then the parent path is 'Core/MainExtension/ParentNode'.
 /// </remarks>
 public string GetParentPath()
 {
     if (Parent is Extension)
     {
         return(((Extension)Parent).Path);
     }
     else if (Parent is ExtensionNodeDescription)
     {
         ExtensionNodeDescription pn = (ExtensionNodeDescription)Parent;
         return(pn.GetParentPath() + "/" + pn.Id);
     }
     else
     {
         return(string.Empty);
     }
 }
コード例 #6
0
ファイル: Extension.cs プロジェクト: mjakeman/Hyena.Addins
        /// <summary>
        /// Gets the node types allowed in this extension.
        /// </summary>
        /// <returns>
        /// The allowed node types.
        /// </returns>
        /// <remarks>
        /// This method only works when the add-in description to which the extension belongs has been
        /// loaded from an add-in registry.
        /// </remarks>
        public ExtensionNodeTypeCollection GetAllowedNodeTypes()
        {
            ObjectDescription ob = GetExtendedObject();
            ExtensionPoint    ep = ob as ExtensionPoint;

            if (ep != null)
            {
                return(ep.NodeSet.GetAllowedNodeTypes());
            }

            ExtensionNodeDescription node = ob as ExtensionNodeDescription;

            if (node != null)
            {
                ExtensionNodeType nt = node.GetNodeType();
                if (nt != null)
                {
                    return(nt.GetAllowedNodeTypes());
                }
            }
            return(new ExtensionNodeTypeCollection());
        }