Exemple #1
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);
 }
        internal void MergeWith(string thisAddinId, ExtensionPoint ep)
        {
            NodeSet.MergeWith(thisAddinId, ep.NodeSet);

            foreach (ConditionTypeDescription cond in ep.Conditions)
            {
                if (cond.AddinId != thisAddinId && !Conditions.Contains(cond))
                {
                    Conditions.Add(cond);
                }
            }
            foreach (string s in ep.Addins)
            {
                if (!Addins.Contains(s))
                {
                    Addins.Add(s);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Gets the object extended by this extension
        /// </summary>
        /// <returns>
        /// The extended object can be an <see cref="ExtensionPoint"/> or
        /// an <see cref="ExtensionNodeDescription"/>.
        /// </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 ObjectDescription GetExtendedObject()
        {
            AddinDescription desc = ParentAddinDescription;

            if (desc == null)
            {
                return(null);
            }
            ExtensionPoint ep = FindExtensionPoint(desc, path);

            if (ep == null && desc.OwnerDatabase != null)
            {
                foreach (Dependency dep in desc.MainModule.Dependencies)
                {
                    AddinDependency adep = dep as AddinDependency;
                    if (adep == null)
                    {
                        continue;
                    }
                    Addin ad = desc.OwnerDatabase.GetInstalledAddin(ParentAddinDescription.Domain, adep.FullAddinId);
                    if (ad != null && ad.Description != null)
                    {
                        ep = FindExtensionPoint(ad.Description, path);
                        if (ep != null)
                        {
                            break;
                        }
                    }
                }
            }
            if (ep != null)
            {
                string subp = path.Substring(ep.Path.Length).Trim('/');
                if (subp.Length == 0)
                {
                    return(ep);                    // The extension is directly extending the extension point
                }
                // The extension is extending a node of the extension point

                return(desc.FindExtensionNode(path, true));
            }
            return(null);
        }
 /// <summary>
 /// Copies another extension point.
 /// </summary>
 /// <param name='ep'>
 /// Extension point from which to copy.
 /// </param>
 public void CopyFrom(ExtensionPoint ep)
 {
     path = ep.path;
     name = ep.name;
     defaultInsertBefore = ep.defaultInsertBefore;
     defaultInsertAfter  = ep.defaultInsertAfter;
     description         = ep.description;
     NodeSet.CopyFrom(ep.NodeSet);
     Conditions.Clear();
     foreach (ConditionTypeDescription cond in ep.Conditions)
     {
         ConditionTypeDescription cc = new ConditionTypeDescription();
         cc.CopyFrom(cond);
         Conditions.Add(cc);
     }
     Addins.Clear();
     foreach (string s in ep.Addins)
     {
         Addins.Add(s);
     }
     rootAddin = ep.rootAddin;
 }
Exemple #5
0
        /// <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());
        }