/// <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); }
void IBinaryXmlElement.Read(BinaryXmlReader reader) { id = reader.ReadStringValue("id"); ns = reader.ReadStringValue("ns"); isroot = reader.ReadBooleanValue("isroot"); name = reader.ReadStringValue("name"); version = reader.ReadStringValue("version"); compatVersion = reader.ReadStringValue("compatVersion"); hasUserId = reader.ReadBooleanValue("hasUserId"); author = reader.ReadStringValue("author"); url = reader.ReadStringValue("url"); copyright = reader.ReadStringValue("copyright"); description = reader.ReadStringValue("description"); category = reader.ReadStringValue("category"); basePath = reader.ReadStringValue("basePath"); sourceAddinFile = reader.ReadStringValue("sourceAddinFile"); defaultEnabled = reader.ReadBooleanValue("defaultEnabled"); domain = reader.ReadStringValue("domain"); mainModule = (ModuleDescription)reader.ReadValue("MainModule"); optionalModules = (ModuleCollection)reader.ReadValue("OptionalModules", new ModuleCollection(this)); nodeSets = (ExtensionNodeSetCollection)reader.ReadValue("NodeSets", new ExtensionNodeSetCollection(this)); extensionPoints = (ExtensionPointCollection)reader.ReadValue("ExtensionPoints", new ExtensionPointCollection(this)); conditionTypes = (ConditionTypeDescriptionCollection)reader.ReadValue("ConditionTypes", new ConditionTypeDescriptionCollection(this)); fileInfo = (object[])reader.ReadValue("FilesInfo", null); localizer = (ExtensionNodeDescription)reader.ReadValue("Localizer"); flags = (AddinFlags)reader.ReadInt32Value("flags"); properties = (AddinPropertyCollectionImpl)reader.ReadValue("Properties", new AddinPropertyCollectionImpl()); if (mainModule != null) { mainModule.SetParent(this); } }
public NodeEditorWidget (DotNetProject project, AddinRegistry reg, ExtensionNodeType ntype, AddinDescription parentAddinDescription, string parentPath, ExtensionNodeDescription node) { this.node = node; this.project = project; tips = new Tooltips (); Spacing = 0; // Header Label label = new Label (); label.Wrap = true; label.WidthRequest = 480; string txt = "<b>" + node.NodeName + "</b>"; if (ntype.Description.Length > 0) txt += "\n" + GLib.Markup.EscapeText (ntype.Description); label.Markup = txt; label.Xalign = 0f; PackStart (label, false, false, 6); PackStart (new HSeparator (), false, false, 0); // Attributes grid = new PropertyGrid (); grid.CurrentObject = new NodeWrapper (project, reg, ntype, parentAddinDescription, parentPath, node); PackStart (grid, true, true, 0); ShowAll (); grid.ShowHelp = true; grid.ShowToolbar = false; }
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); } }
public void Fill (ExtensionNodeDescription node) { ExtensionNodeType ntype = node.GetNodeType (); labelName.Markup = "<small>Extension Node</small>\n<big><b>" + GLib.Markup.EscapeText (ntype.NodeName) + "</b></big>"; if (!string.IsNullOrEmpty (ntype.Description)) labelDesc.Text = ntype.Description; else labelDesc.Text = AddinManager.CurrentLocalizer.GetString ("No additional documentation"); uint row = 0; foreach (var att in node.Attributes) { Gtk.Label lab = new Gtk.Label (); lab.Markup = "<b>" + GLib.Markup.EscapeText (att.Name) + ":</b>"; lab.UseUnderline = false; lab.Xalign = 0; tableAtts.Attach (lab, 0, 1, row, row + 1); Gtk.Table.TableChild ct = (Gtk.Table.TableChild) tableAtts [lab]; ct.XOptions = Gtk.AttachOptions.Fill; lab = new Gtk.Label (att.Value); lab.UseUnderline = false; lab.Xalign = 0; lab.Wrap = true; tableAtts.Attach (lab, 1, 2, row, row + 1); ct = (Gtk.Table.TableChild) tableAtts [lab]; ct.XOptions = Gtk.AttachOptions.Fill; row++; } tableAtts.ShowAll (); }
public ExtensionNodeDescription AddExtensionNode(string path, string nodeName) { ExtensionNodeDescription node = new ExtensionNodeDescription(nodeName); GetExtension(path).ExtensionNodes.Add(node); return(node); }
internal ExtensionNodeDescription FindExtensionNode(string path, bool lookInDeps) { // Look in the extensions of this add-in foreach (Extension ext in MainModule.Extensions) { if (path.StartsWith(ext.Path + "/")) { string subp = path.Substring(ext.Path.Length).Trim('/'); ExtensionNodeDescriptionCollection nodes = ext.ExtensionNodes; ExtensionNodeDescription node = null; foreach (string p in subp.Split('/')) { if (p.Length == 0) { continue; } node = nodes [p]; if (node == null) { break; } nodes = node.ChildNodes; } if (node != null) { return(node); } } } if (!lookInDeps || OwnerDatabase == null) { return(null); } // Look in dependencies foreach (Dependency dep in MainModule.Dependencies) { AddinDependency adep = dep as AddinDependency; if (adep == null) { continue; } Addin ad = OwnerDatabase.GetInstalledAddin(Domain, adep.FullAddinId); if (ad != null && ad.Description != null) { ExtensionNodeDescription node = ad.Description.FindExtensionNode(path, false); if (node != null) { return(node); } } } return(null); }
public NodeEditorDialog (DotNetProject project, AddinRegistry reg, ExtensionNodeType ntype, AddinDescription parentAddinDescription, string parentPath, ExtensionNodeDescription node) { editor = new NodeEditorWidget (project, reg, ntype, parentAddinDescription, parentPath, node); editor.BorderWidth = 12; this.VBox.PackStart (editor, true, true, 0); this.AddButton (Stock.Cancel, ResponseType.Cancel); this.AddButton (Stock.Ok, ResponseType.Ok); this.DefaultWidth = 400; ShowAll (); }
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); } }
/// <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); } }
public ExtensionEditor (ExtensionNodeDescription node) { HBox fieldsBox = new HBox (); fieldsBox.Spacing = 3; Gtk.Label lab = new Gtk.Label (); lab.Markup = "<b>" + node.NodeName + "</b>"; fieldsBox.PackStart (lab, false, false, 0); ExtensionNodeType nt = node.GetNodeType (); if (nt == null) { fieldsBox.PackStart (new Gtk.Label ("Unknown node type"), false, false, 0); } else { AddAttribute (fieldsBox, node, "id", "System.String", false); Console.WriteLine ("ppAA: " + nt.Attributes.Count); foreach (NodeTypeAttribute at in nt.Attributes) { AddAttribute (fieldsBox, node, at.Name, at.Type, at.Required); } } PackStart (fieldsBox, false, false, 0); ShowAll (); }
/// <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()); }
public NodeWrapper (DotNetProject project, AddinRegistry reg, ExtensionNodeType ntype, AddinDescription parentAddinDescription, string parentPath, ExtensionNodeDescription node) { List<PropertyDescriptor> props = new List<PropertyDescriptor> (); string mainCategory = AddinManager.CurrentLocalizer.GetString ("Node Attributes"); PropertyDescriptor prop = new MyPropertyDescriptor ("id", typeof(String), AddinManager.CurrentLocalizer.GetString ("Identifier of the extension node"), mainCategory, node); props.Add (prop); foreach (NodeTypeAttribute att in ntype.Attributes) { Type pt = Type.GetType (att.Type); if (pt == null) pt = typeof(string); prop = new MyPropertyDescriptor (att.Name, pt, att.Description, mainCategory, node); props.Add (prop); } /* int n = 1; foreach (ExtensionNodeDescription en in AddinData.GetExtensionNodes (reg, parentAddinDescription, parentPath)) { if (en.Id.Length > 0) { insBeforeCombo.AppendText (en.Id); insAfterCombo.AppendText (en.Id); if (en.Id == node.InsertBefore) insBeforeCombo.Active = n; if (en.Id == node.InsertAfter) insAfterCombo.Active = n; } n++; } */ prop = new MyPropertyDescriptor ("insertBefore", typeof(String), AddinManager.CurrentLocalizer.GetString ("Insert Before"), AddinManager.CurrentLocalizer.GetString ("Placement"), node); props.Add (prop); prop = new MyPropertyDescriptor ("insertAfter", typeof(String), AddinManager.CurrentLocalizer.GetString ("Insert After"), AddinManager.CurrentLocalizer.GetString ("Placement"), node); props.Add (prop); properties = new PropertyDescriptorCollection (props.ToArray ()); }
internal Condition (AddinEngine addinEngine, ExtensionNodeDescription element, BaseCondition parent): base (parent) { this.addinEngine = addinEngine; typeId = element.GetAttribute ("id"); addin = element.GetAttribute (SourceAddinAttribute); node = element; }
void CreateNode (TreeIter it, Extension ext, ExtensionNodeDescription node, ExtensionNodeType nt) { ExtensionNodeDescription newNode = new ExtensionNodeDescription (nt.NodeName); if (ext != null) { if (ext.Parent == null) adesc.MainModule.Extensions.Add (ext); ext.ExtensionNodes.Add (newNode); } else node.ChildNodes.Add (newNode); TreeIter nit = AddNode (it, newNode); tree.ExpandRow (store.GetPath (it), false); tree.Selection.SelectIter (nit); NotifyChanged (); }
void IBinaryXmlElement.Read (BinaryXmlReader reader) { id = reader.ReadStringValue ("id"); ns = reader.ReadStringValue ("ns"); isroot = reader.ReadBooleanValue ("isroot"); name = reader.ReadStringValue ("name"); version = reader.ReadStringValue ("version"); compatVersion = reader.ReadStringValue ("compatVersion"); hasUserId = reader.ReadBooleanValue ("hasUserId"); author = reader.ReadStringValue ("author"); url = reader.ReadStringValue ("url"); copyright = reader.ReadStringValue ("copyright"); description = reader.ReadStringValue ("description"); category = reader.ReadStringValue ("category"); basePath = reader.ReadStringValue ("basePath"); sourceAddinFile = reader.ReadStringValue ("sourceAddinFile"); defaultEnabled = reader.ReadBooleanValue ("defaultEnabled"); domain = reader.ReadStringValue ("domain"); mainModule = (ModuleDescription) reader.ReadValue ("MainModule"); optionalModules = (ModuleCollection) reader.ReadValue ("OptionalModules", new ModuleCollection (this)); nodeSets = (ExtensionNodeSetCollection) reader.ReadValue ("NodeSets", new ExtensionNodeSetCollection (this)); extensionPoints = (ExtensionPointCollection) reader.ReadValue ("ExtensionPoints", new ExtensionPointCollection (this)); conditionTypes = (ConditionTypeDescriptionCollection) reader.ReadValue ("ConditionTypes", new ConditionTypeDescriptionCollection (this)); fileInfo = (object[]) reader.ReadValue ("FilesInfo", null); localizer = (ExtensionNodeDescription) reader.ReadValue ("Localizer"); if (mainModule != null) mainModule.SetParent (this); }
void AddNodeSorted(ExtensionNodeDescriptionCollection list, ExtensionNodeDescription node, ref int curPos) { // Adds the node at the correct position, taking into account insertbefore and insertafter if (node.InsertAfter.Length > 0) { string afterId = node.InsertAfter; for (int n=0; n<list.Count; n++) { if (list[n].Id == afterId) { list.Insert (n + 1, node); curPos = n + 2; return; } } } else if (node.InsertBefore.Length > 0) { string beforeId = node.InsertBefore; for (int n=0; n<list.Count; n++) { if (list[n].Id == beforeId) { list.Insert (n, node); curPos = n + 1; return; } } } if (curPos == -1) list.Add (node); else list.Insert (curPos++, node); }
internal Condition (ExtensionNodeDescription element, BaseCondition parent): base (parent) { typeId = element.GetAttribute ("id"); node = element; }
TreeIter AddNode (TreeIter it, ExtensionNodeDescription node) { string txt = GLib.Markup.EscapeText (node.NodeName) + " (<i>"; foreach (NodeAttribute at in node.Attributes) txt += at.Name + "=\"" + GLib.Markup.EscapeText (at.Value) + "\" "; txt += "</i>)"; it = store.AppendValues (it, txt, null, null, node, pixExtensionNode, true, null); foreach (ExtensionNodeDescription cnode in node.ChildNodes) AddNode (it, cnode); return it; }
public ExtensionNode ReadNode(TreeNode tnode, string addin, ExtensionNodeType ntype, ExtensionNodeDescription elem, ModuleDescription module) { try { if (ntype.Type == null) { if (!InitializeNodeType (ntype)) return null; } ExtensionNode node; node = Activator.CreateInstance (ntype.Type) as ExtensionNode; if (node == null) { addinEngine.ReportError ("Extension node type '" + ntype.Type + "' must be a subclass of ExtensionNode", addin, null, false); return null; } tnode.AttachExtensionNode (node); node.SetData (addinEngine, addin, ntype, module); node.Read (elem); return node; } catch (Exception ex) { addinEngine.ReportError ("Could not read extension node of type '" + ntype.Type + "' from extension path '" + tnode.GetPath() + "'", addin, ex, false); return null; } }
BaseCondition ReadComplexCondition(ExtensionNodeDescription elem, BaseCondition parentCondition) { if (elem.NodeName == "Or" || elem.NodeName == "And" || elem.NodeName == "Not") { ArrayList conds = new ArrayList (); foreach (ExtensionNodeDescription celem in elem.ChildNodes) { conds.Add (ReadComplexCondition (celem, null)); } if (elem.NodeName == "Or") return new OrCondition ((BaseCondition[]) conds.ToArray (typeof(BaseCondition)), parentCondition); else if (elem.NodeName == "And") return new AndCondition ((BaseCondition[]) conds.ToArray (typeof(BaseCondition)), parentCondition); else { if (conds.Count != 1) { addinEngine.ReportError ("Invalid complex condition element '" + elem.NodeName + "'. 'Not' condition can only have one parameter.", null, null, false); return new NullCondition (); } return new NotCondition ((BaseCondition) conds [0], parentCondition); } } if (elem.NodeName == "Condition") { return new Condition (AddinEngine, elem, parentCondition); } addinEngine.ReportError ("Invalid complex condition element '" + elem.NodeName + "'.", null, null, false); return new NullCondition (); }
public void AddNodeBefore (object data) { DotNetProject p = (DotNetProject) CurrentNode.GetParentDataItem (typeof(Project), false); AddinData adata = p.GetAddinData (); Extension en = GetExtension (); ExtensionNodeType ntype = (ExtensionNodeType) data; ExtensionNodeDescription newNode = new ExtensionNodeDescription (ntype.NodeName); en.ExtensionNodes.Add (newNode); CurrentNode.Expanded = true; adata.SaveAddinManifest (); adata.NotifyChanged (false); DispatchService.GuiDispatch (delegate { ITreeNavigator nav = Tree.GetNodeAtObject (new ExtensionNodeInfo (newNode, false)); if (nav != null) nav.Selected = true; }); }
void AddAttribute (HBox fieldsBox, ExtensionNodeDescription node, string name, string type, bool req) { HBox box = new HBox (); Gtk.Label lab = new Gtk.Label (); lab.Markup = "<b>" + name + "</b>=\""; box.PackStart (lab, false, false, 0); Gtk.Entry entry = new AutoSizeEntry (); entry.Text = node.GetAttribute (name); box.PackStart (entry, false, false, 0); box.PackStart (new Gtk.Label ("\" "), false, false, 0); fieldsBox.PackStart (box, false, false, 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; }
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); }
void ScanAssemblyAddinHeaders(IAssemblyReflector reflector, AddinDescription config, object asm, AddinScanResult scanResult) { // Get basic add-in information AddinAttribute att = (AddinAttribute) reflector.GetCustomAttribute (asm, typeof(AddinAttribute), false); if (att != null) { if (att.Id.Length > 0) config.LocalId = att.Id; if (att.Version.Length > 0) config.Version = att.Version; if (att.Namespace.Length > 0) config.Namespace = att.Namespace; if (att.Category.Length > 0) config.Category = att.Category; if (att.CompatVersion.Length > 0) config.CompatVersion = att.CompatVersion; if (att.Url.Length > 0) config.Url = att.Url; config.IsRoot = att is AddinRootAttribute; config.EnabledByDefault = att.EnabledByDefault; config.Flags = att.Flags; } // Author attributes object[] atts = reflector.GetCustomAttributes (asm, typeof(AddinAuthorAttribute), false); foreach (AddinAuthorAttribute author in atts) { if (config.Author.Length == 0) config.Author = author.Name; else config.Author += ", " + author.Name; } // Name atts = reflector.GetCustomAttributes (asm, typeof(AddinNameAttribute), false); foreach (AddinNameAttribute at in atts) { if (string.IsNullOrEmpty (at.Locale)) config.Name = at.Name; else config.Properties.SetPropertyValue ("Name", at.Name, at.Locale); } // Description object catt = reflector.GetCustomAttribute (asm, typeof(AssemblyDescriptionAttribute), false); if (catt != null && config.Description.Length == 0) config.Description = ((AssemblyDescriptionAttribute)catt).Description; atts = reflector.GetCustomAttributes (asm, typeof(AddinDescriptionAttribute), false); foreach (AddinDescriptionAttribute at in atts) { if (string.IsNullOrEmpty (at.Locale)) config.Description = at.Description; else config.Properties.SetPropertyValue ("Description", at.Description, at.Locale); } // Copyright catt = reflector.GetCustomAttribute (asm, typeof(AssemblyCopyrightAttribute), false); if (catt != null && config.Copyright.Length == 0) config.Copyright = ((AssemblyCopyrightAttribute)catt).Copyright; // Localizer AddinLocalizerGettextAttribute locat = (AddinLocalizerGettextAttribute) reflector.GetCustomAttribute (asm, typeof(AddinLocalizerGettextAttribute), false); if (locat != null) { ExtensionNodeDescription node = new ExtensionNodeDescription (); if (!string.IsNullOrEmpty (locat.Catalog)) node.SetAttribute ("catalog", locat.Catalog); if (!string.IsNullOrEmpty (locat.Location)) node.SetAttribute ("location", locat.Catalog); config.Localizer = node; } // Optional modules atts = reflector.GetCustomAttributes (asm, typeof(AddinModuleAttribute), false); foreach (AddinModuleAttribute mod in atts) { if (mod.AssemblyFile.Length > 0) { ModuleDescription module = new ModuleDescription (); module.Assemblies.Add (mod.AssemblyFile); config.OptionalModules.Add (module); } } }
void VerifyConditionNode (string location, ExtensionNodeDescription node, StringCollection errors) { string nodeName = node.NodeName; if (nodeName != "Or" && nodeName != "And" && nodeName != "Condition") { errors.Add (location + "ComplexCondition: Invalid condition element: " + nodeName); return; } foreach (ExtensionNodeDescription cnode in node.ChildNodes) VerifyConditionNode (location, cnode, errors); }
public void AddNodeBefore (object data) { DotNetProject p = (DotNetProject) CurrentNode.GetParentDataItem (typeof(Project), false); AddinData adata = p.GetAddinData (); ExtensionNodeInfo en = (ExtensionNodeInfo) CurrentNode.DataItem; ExtensionNodeType ntype = (ExtensionNodeType) data; ExtensionNodeDescription newNode = new ExtensionNodeDescription (ntype.NodeName); InsertNode (adata, en, DropPosition.Before, newNode); adata.CachedAddinManifest.Save (); adata.NotifyChanged (false); }
public MyPropertyDescriptor (string name, Type type, string desc, string category, ExtensionNodeDescription node): base (name, new Attribute [0]) { if (type == typeof(Type)) { type = typeof(string); editorType = typeof(TypeCellEditor); } this.name = name; this.type = type; this.node = node; this.desc = desc; this.category = category; }
ExtensionNodeDescription InsertNode (AddinData adata, ExtensionNodeInfo refNode, DropPosition pos, ExtensionNodeDescription newNode) { ExtensionNodeDescriptionCollection nodes = null; newNode.InsertBefore = ""; newNode.InsertAfter = ""; if (refNode.CanModify) { if (pos == DropPosition.Into) nodes = refNode.Node.ChildNodes; else if (refNode.Node.Parent is ExtensionNodeDescription) nodes = ((ExtensionNodeDescription)refNode.Node.Parent).ChildNodes; } else { if (pos == DropPosition.After) newNode.InsertAfter = refNode.Node.Id; else if (pos == DropPosition.Before) newNode.InsertBefore = refNode.Node.Id; } if (nodes == null) { string path = refNode.Node.GetParentPath (); if (pos == DropPosition.Into) path += "/" + refNode.Node.Id; Extension ext = adata.CachedAddinManifest.MainModule.GetExtension (path); nodes = ext.ExtensionNodes; } for (int n = 0; n < nodes.Count; n++) { ExtensionNodeDescription node = nodes [n]; if (node == refNode.Node) { if (pos == DropPosition.After) n++; nodes.Insert (n, newNode); return newNode; } } nodes.Add (newNode); return newNode; }
BaseCondition ReadComplexCondition (ExtensionNodeDescription elem, BaseCondition parentCondition) { if (elem.NodeName == "Or" || elem.NodeName == "And") { ArrayList conds = new ArrayList (); foreach (ExtensionNodeDescription celem in elem.ChildNodes) { conds.Add (ReadComplexCondition (celem, null)); } if (elem.NodeName == "Or") return new OrCondition ((BaseCondition[]) conds.ToArray (typeof(BaseCondition)), parentCondition); else return new AndCondition ((BaseCondition[]) conds.ToArray (typeof(BaseCondition)), parentCondition); } if (elem.NodeName == "Condition") { return new Condition (elem, parentCondition); } AddinManager.ReportError ("Invalid complex condition element '" + elem.NodeName + "'.", null, null, false); return new NullCondition (); }