public void Fill (AddinDescription desc, AddinData data) { adesc = desc; comboNs.Entry.Text = desc.Namespace; entryVersion.Text = desc.Version; entryCompatVersion.Text = desc.CompatVersion; textviewDesc.Buffer.Text = desc.Description; entryAuthor.Text = desc.Author; entryLicense.Text = desc.Copyright; entryUrl.Text = desc.Url; checkIsRoot.Active = desc.IsRoot; notebook.ShowTabs = false; notebook.ShowBorder = false; if (desc.LocalId.Length == 0) { defaultId = System.IO.Path.GetFileNameWithoutExtension (data.Project.GetOutputFileName (ConfigurationSelector.Default)); entryIdentifier.Text = defaultId; } else entryIdentifier.Text = desc.LocalId; if (desc.Name.Length == 0) { defaultName = entryIdentifier.Text; entryName.Text = defaultName; } else entryName.Text = desc.Name; extensionEditor.SetData (adesc, data); extensionPointsEditor.SetData (adesc, data); }
public SelectNodeSetDialog (DotNetProject project, AddinRegistry registry, AddinDescription desc) { this.Build(); this.project = project; this.registry = registry; this.desc = desc; foreach (AddinDependency adep in desc.MainModule.Dependencies) { Addin addin = registry.GetAddin (adep.FullAddinId); if (addin != null && addin.Description != null) { foreach (ExtensionNodeSet ns in addin.Description.ExtensionNodeSets) { combo.AppendText (ns.Id); sets [ns.Id] = ns; } } } foreach (ExtensionNodeSet ns in desc.ExtensionNodeSets) { combo.AppendText (ns.Id); sets [ns.Id] = ns; } nodeseteditor.AllowEditing = false; buttonOk.Sensitive = false; }
public void RegisterNodeSet (AddinDescription description, ExtensionNodeSet nset) { List<RootExtensionPoint> extensions; if (nodeSetHash.TryGetValue (nset.Id, out extensions)) { // Extension point already registered List<ExtensionPoint> compatExtensions = GetCompatibleExtensionPoints (nset.Id, description, description.MainModule, extensions); if (compatExtensions.Count > 0) { foreach (ExtensionPoint einfo in compatExtensions) einfo.NodeSet.MergeWith (null, nset); return; } } // Create a new extension set RootExtensionPoint rep = new RootExtensionPoint (); rep.ExtensionPoint = new ExtensionPoint (); rep.ExtensionPoint.SetNodeSet (nset); rep.ExtensionPoint.RootAddin = description.AddinId; rep.ExtensionPoint.Path = nset.Id; rep.Description = description; if (extensions == null) { extensions = new List<RootExtensionPoint> (); nodeSetHash [nset.Id] = extensions; } extensions.Add (rep); }
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; }
public static AddinDescription Read(Stream stream, string basePath) { AddinDescription config = new AddinDescription(); try { config.configDoc = new XmlDocument(); config.configDoc.Load(stream); } catch (Exception ex) { throw new InvalidOperationException("The add-in configuration file is invalid.", ex); } XmlElement elem = config.configDoc.DocumentElement; config.id = elem.GetAttribute("id"); config.ns = elem.GetAttribute("namespace"); config.name = elem.GetAttribute("name"); config.version = elem.GetAttribute("version"); config.compatVersion = elem.GetAttribute("compatVersion"); config.author = elem.GetAttribute("author"); config.url = elem.GetAttribute("url"); config.copyright = elem.GetAttribute("copyright"); config.description = elem.GetAttribute("description"); config.category = elem.GetAttribute("category"); config.basePath = elem.GetAttribute("basePath"); config.isroot = elem.GetAttribute("isroot") == "true" || elem.GetAttribute("isroot") == "yes"; return(config); }
public static string GetDisplayName (AddinDescription ad) { if (!string.IsNullOrEmpty (ad.Name)) return ad.Name; else return ad.LocalId; }
void LoadAddin(AddinDescription addin, List<ConfigurablePlugin> plugins) { if (addin == null) { vbox1.Visible = false; return; } vbox1.Visible = true; namelabel.Text = addin.Name; desclabel.Text = addin.Description; authorlabel.Text = addin.Author; filelabel.Text = addin.AddinFile; if (plugins != null && plugins.Count > 0) { configframe.Visible = true; foreach (Widget w in configbox.Children) { configbox.Remove (w); w.Destroy (); } foreach (ConfigurablePlugin plugin in plugins) { foreach (AttributeAndProperty attrprop in plugin.Properties) { if (attrprop.Property.PropertyType == typeof(Boolean)) { CheckButton button = new CheckButton (attrprop.Attribute.description); button.Active = (bool)attrprop.Property.GetValue (plugin, null); button.Clicked += (sender, e) => { attrprop.Property.SetValue (plugin, button.Active, null); }; button.Show (); configbox.PackStart (button, false, true, 0); } } } } else { configframe.Visible = false; } }
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 (); }
internal static AddinDescription ReadBinary(FileDatabase fdb, string configFile) { AddinDescription description = (AddinDescription)fdb.ReadSharedObject(configFile, typeMap); if (description != null) { description.FileName = configFile; description.canWrite = !fdb.IgnoreDescriptionData; } return(description); }
ExtensionPoint FindExtensionPoint(AddinDescription desc, string path) { foreach (ExtensionPoint ep in desc.ExtensionPoints) { if (ep.Path == path || path.StartsWith(ep.Path + "/")) { return(ep); } } return(null); }
public NewExtensionPointDialog (DotNetProject project, AddinRegistry registry, AddinDescription adesc, ExtensionPoint ep) { this.Build(); this.ep = ep; this.project = project; this.registry = registry; this.adesc = adesc; notebook.Page = 0; Fill (); }
public static void AddDependencies (AddinDescription desc, AddinScanResult scanResult) { // Not implemented in AddinScanResult to avoid making AddinDescription remotable foreach (ModuleDescription mod in desc.AllModules) { foreach (Dependency dep in mod.Dependencies) { AddinDependency adep = dep as AddinDependency; if (adep == null) continue; string depid = Addin.GetFullId (desc.Namespace, adep.AddinId, adep.Version); scanResult.AddAddinToUpdateRelations (depid); } } }
internal static AddinDescription ReadHostBinary(FileDatabase fdb, string basePath, string addinId, string addinFile) { string fileName; AddinDescription description = (AddinDescription)fdb.ReadSharedObject(basePath, addinId, ".mroot", Util.GetFullPath(addinFile), typeMap, out fileName); if (description != null) { description.FileName = fileName; description.fromBinaryFile = true; description.canWrite = !fdb.IgnoreDescriptionData; } return(description); }
public void Fill (AddinRegistry reg, AddinDescription localDesc, AddinDescription pdesc, string path) { List<AddinDescription> deps = new List<AddinDescription> (); foreach (Dependency dep in pdesc.MainModule.Dependencies) { AddinDependency adep = dep as AddinDependency; if (adep == null) continue; Addin addin = reg.GetAddin (adep.FullAddinId); if (addin != null) deps.Add (addin.Description); } Fill (localDesc, pdesc, path, deps); }
public void RegisterAddinRootExtensionPoint (AddinDescription description, ExtensionPoint ep) { ArrayList list = (ArrayList) pathHash [ep.Path]; if (list == null) { list = new ArrayList (); pathHash [ep.Path] = list; } RootExtensionPoint rep = new RootExtensionPoint (); rep.Description = description; rep.ExtensionPoint = ep; ep.RootAddin = description.AddinId; list.Add (rep); }
public static AddinDescription Read(Stream stream, string basePath) { AddinDescription config = new AddinDescription(); try { config.configDoc = new XmlDocument(); config.configDoc.Load(stream); } catch (Exception ex) { throw new InvalidOperationException("The add-in configuration file is invalid: " + ex.Message, ex); } XmlElement elem = config.configDoc.DocumentElement; config.id = elem.GetAttribute("id"); config.ns = elem.GetAttribute("namespace"); config.name = elem.GetAttribute("name"); config.version = elem.GetAttribute("version"); config.compatVersion = elem.GetAttribute("compatVersion"); config.author = elem.GetAttribute("author"); config.url = elem.GetAttribute("url"); config.copyright = elem.GetAttribute("copyright"); config.description = elem.GetAttribute("description"); config.category = elem.GetAttribute("category"); config.basePath = elem.GetAttribute("basePath"); string s = elem.GetAttribute("isRoot"); if (s.Length == 0) { s = elem.GetAttribute("isroot"); } config.isroot = s == "true" || s == "yes"; s = elem.GetAttribute("defaultEnabled"); config.defaultEnabled = s.Length == 0 || s == "true" || s == "yes"; XmlElement localizerElem = (XmlElement)elem.SelectSingleNode("Localizer"); if (localizerElem != null) { config.localizer = new ExtensionNodeDescription(localizerElem); } if (config.id.Length > 0) { config.hasUserId = true; } return(config); }
public void RegisterAddinRootNodeSet (AddinDescription description, ExtensionNodeSet nodeSet) { ArrayList list = (ArrayList) nodeSetHash [nodeSet.Id]; if (list == null) { list = new ArrayList (); nodeSetHash [nodeSet.Id] = list; } RootExtensionPoint rep = new RootExtensionPoint (); rep.Description = description; ExtensionPoint ep = new ExtensionPoint (); ep.RootAddin = description.AddinId; ep.SetNodeSet (nodeSet); rep.ExtensionPoint = ep; list.Add (rep); }
public void Fill (AddinDescription localDesc, AddinDescription pdesc, string path, List<AddinDescription> contributorAddins) { var extensions = new List<Extension> (); var extNodes = new List<ExtensionNodeDescription> (); SortReferences (contributorAddins); foreach (AddinDescription desc in contributorAddins) CollectExtensions (desc, path, extensions, extNodes); CollectExtensions (pdesc, path, extensions, extNodes); foreach (var node in extNodes) nodes.Add (new ExtensionNodeInfo (node, node.ParentAddinDescription == localDesc)); foreach (Extension ext in extensions) { bool canModify = ext.ParentAddinDescription == localDesc; string subp = ext.Path.Substring (path.Length); List<ExtensionNodeInfo> list = nodes; foreach (string p in subp.Split ('/')) { if (p.Length == 0) continue; int i = FindNode (list, p); if (i == -1) { list = null; break; } list = list [i].Expand (); } if (list != null) { int insertPos = list.Count; foreach (ExtensionNodeDescription n in ext.ExtensionNodes) { if (!string.IsNullOrEmpty (n.InsertAfter)) { int i = FindNode (list, n.InsertAfter); if (i != -1) insertPos = i + 1; } else if (!string.IsNullOrEmpty (n.InsertBefore)) { int i = FindNode (list, n.InsertBefore); if (i != -1) insertPos = i; } list.Insert (insertPos++, new ExtensionNodeInfo (n, canModify)); } } } StoreOrder (nodes); }
public void PropertyLocalization() { AddinDescription desc = new AddinDescription (); desc.Properties.SetPropertyValue ("prop1", "val1"); Assert.AreEqual ("val1", desc.Properties.GetPropertyValue ("prop1")); Assert.AreEqual ("val1", desc.Properties.GetPropertyValue ("prop1", "en")); Assert.AreEqual ("val1", desc.Properties.GetPropertyValue ("prop1", "en-US")); Assert.AreEqual ("val1", desc.Properties.GetPropertyValue ("prop1", "en_US")); Assert.AreEqual ("val1", desc.Properties.GetPropertyValue ("prop1", null)); desc.Properties.SetPropertyValue ("prop2", "valCa", "ca"); Assert.AreEqual ("valCa", desc.Properties.GetPropertyValue ("prop2")); Assert.AreEqual ("valCa", desc.Properties.GetPropertyValue ("prop2", "ca")); Assert.AreEqual ("valCa", desc.Properties.GetPropertyValue ("prop2", "ca-ES")); Assert.AreEqual ("valCa", desc.Properties.GetPropertyValue ("prop2", "ca_ES")); Assert.AreEqual ("valCa", desc.Properties.GetPropertyValue ("prop2", "ca-AN")); Assert.AreEqual ("valCa", desc.Properties.GetPropertyValue ("prop2", "ca_AN")); Assert.IsEmpty (desc.Properties.GetPropertyValue ("prop2", "en")); Assert.IsEmpty (desc.Properties.GetPropertyValue ("prop2", "en-US")); Assert.IsEmpty (desc.Properties.GetPropertyValue ("prop2", "en_US")); Assert.IsEmpty (desc.Properties.GetPropertyValue ("prop2", null)); desc.Properties.SetPropertyValue ("prop2", "valCaEs", "ca_ES"); Assert.AreEqual ("valCaEs", desc.Properties.GetPropertyValue ("prop2")); Assert.AreEqual ("valCa", desc.Properties.GetPropertyValue ("prop2", "ca")); Assert.AreEqual ("valCaEs", desc.Properties.GetPropertyValue ("prop2", "ca-ES")); Assert.AreEqual ("valCaEs", desc.Properties.GetPropertyValue ("prop2", "ca_ES")); Assert.AreEqual ("valCa", desc.Properties.GetPropertyValue ("prop2", "ca-AN")); Assert.AreEqual ("valCa", desc.Properties.GetPropertyValue ("prop2", "ca_AN")); Assert.IsEmpty (desc.Properties.GetPropertyValue ("prop2", "en")); Assert.IsEmpty (desc.Properties.GetPropertyValue ("prop2", "en-US")); Assert.IsEmpty (desc.Properties.GetPropertyValue ("prop2", "en_US")); Assert.IsEmpty (desc.Properties.GetPropertyValue ("prop2", null)); desc.Properties.SetPropertyValue ("prop2", "val4", null); Assert.AreEqual ("valCaEs", desc.Properties.GetPropertyValue ("prop2")); Assert.AreEqual ("valCa", desc.Properties.GetPropertyValue ("prop2", "ca")); Assert.AreEqual ("valCaEs", desc.Properties.GetPropertyValue ("prop2", "ca-ES")); Assert.AreEqual ("valCaEs", desc.Properties.GetPropertyValue ("prop2", "ca_ES")); Assert.AreEqual ("valCa", desc.Properties.GetPropertyValue ("prop2", "ca-AN")); Assert.AreEqual ("valCa", desc.Properties.GetPropertyValue ("prop2", "ca_AN")); Assert.AreEqual ("val4", desc.Properties.GetPropertyValue ("prop2", "en")); Assert.AreEqual ("val4", desc.Properties.GetPropertyValue ("prop2", "en-US")); Assert.AreEqual ("val4", desc.Properties.GetPropertyValue ("prop2", "en_US")); Assert.AreEqual ("val4", desc.Properties.GetPropertyValue ("prop2", null)); }
public void Fill (AddinDescription desc) { string name = desc.Name; if (string.IsNullOrEmpty (name)) name = desc.LocalId; labelName.Markup = "<small>Add-in</small>\n<big><b>" + GLib.Markup.EscapeText (name) + "</b></big>"; if (!string.IsNullOrEmpty (desc.Description)) labelDesc.Text = desc.Description; else labelDesc.Hide (); labelId.Text = desc.LocalId; labelNamespace.Text = desc.Namespace; labelVersion.Text = desc.Version; labelAuthor.Text = desc.Author; labelCopyright.Text = desc.Copyright; }
/// <summary> /// Gets the object extended by this extension /// </summary> /// <returns> /// The extended object can be an <see cref="Mono.Addins.Description.ExtensionPoint"/> or /// an <see cref="Mono.Addins.Description.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); }
public ExtensionSelectorDialog (AddinRegistry reg, AddinDescription adesc, bool isRoot, bool addinSelector) { this.Build(); this.addinSelector = addinSelector; this.registry = reg; this.adesc = adesc; this.isRoot = isRoot; pixCategory = ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.ClosedFolder, IconSize.Menu); pixNamespace = ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.NameSpace, IconSize.Menu); pixAddin = ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.Addin, IconSize.Menu); pixLocalAddin = ImageService.GetPixbuf ("md-addinauthoring-current-addin", IconSize.Menu); store = new TreeStore (typeof(string), typeof(object), typeof(ExtensionPoint), typeof(bool), typeof(bool), typeof(Gdk.Pixbuf), typeof(bool), typeof(bool)); TreeViewColumn col = new TreeViewColumn (); CellRendererPixbuf cpix = new CellRendererPixbuf (); col.PackStart (cpix, false); col.AddAttribute (cpix, "pixbuf", ColIcon); col.AddAttribute (cpix, "visible", ColShowIcon); CellRendererToggle ctog = new CellRendererToggle (); ctog.Toggled += OnToggled; ctog.Yalign = 0; ctog.Ypad = 5; col.PackStart (ctog, false); col.AddAttribute (ctog, "active", ColChecked); col.AddAttribute (ctog, "visible", ColShowCheck); CellRendererText crt = new CellRendererText (); crt.Yalign = 0; col.PackStart (crt, true); col.AddAttribute (crt, "markup", ColLabel); tree.AppendColumn (col); Fill (); tree.HeadersVisible = false; tree.Model = store; tree.TestExpandRow += new Gtk.TestExpandRowHandler (OnTestExpandRow); }
internal void MergeExternalData(AddinDescription other) { // Removes extension types and extension sets coming from other add-ins. foreach (ExtensionPoint ep in other.ExtensionPoints) { ExtensionPoint tep = ExtensionPoints [ep.Path]; if (tep != null) { tep.MergeWith(AddinId, ep); } } foreach (ExtensionNodeSet ns in other.ExtensionNodeSets) { ExtensionNodeSet tns = ExtensionNodeSets [ns.Id]; if (tns != null) { tns.MergeWith(AddinId, ns); } } }
void GetAllowedNodeTypes(Hashtable visitedSets, ExtensionNodeTypeCollection col) { if (Id.Length > 0) { if (visitedSets.Contains(Id)) { return; } visitedSets [Id] = Id; } // Gets all allowed node types, including those defined in node sets // It only works for descriptions generated from a registry foreach (ExtensionNodeType nt in NodeTypes) { col.Add(nt); } AddinDescription desc = ParentAddinDescription; if (desc == null || desc.OwnerDatabase == null) { return; } foreach (string[] ns in NodeSets.InternalList) { string startAddin = ns [1]; if (startAddin == null || startAddin.Length == 0) { startAddin = desc.AddinId; } ExtensionNodeSet nset = desc.OwnerDatabase.FindNodeSet(ParentAddinDescription.Domain, startAddin, ns[0]); if (nset != null) { nset.GetAllowedNodeTypes(visitedSets, col); } } }
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 ()); }
public bool DependsOnAddin(string addinId) { AddinDescription desc = Parent as AddinDescription; if (desc == null) { throw new InvalidOperationException(); } foreach (Dependency dep in Dependencies) { AddinDependency adep = dep as AddinDependency; if (adep == null) { continue; } if (Addin.GetFullId(desc.Namespace, adep.AddinId, adep.Version) == addinId) { return(true); } } return(false); }
internal static AddinDescription Merge(AddinDescription desc1, AddinDescription desc2) { if (!desc2.IsExtensionModel) { AddinDescription tmp = desc1; desc1 = desc2; desc2 = tmp; } ((AddinPropertyCollectionImpl)desc1.Properties).AddRange(desc2.Properties); desc1.ExtensionPoints.AddRange(desc2.ExtensionPoints); desc1.ExtensionNodeSets.AddRange(desc2.ExtensionNodeSets); desc1.ConditionTypes.AddRange(desc2.ConditionTypes); desc1.OptionalModules.AddRange(desc2.OptionalModules); foreach (string s in desc2.MainModule.Assemblies) { desc1.MainModule.Assemblies.Add(s); } foreach (string s in desc2.MainModule.DataFiles) { desc1.MainModule.DataFiles.Add(s); } desc1.MainModule.Dependencies.AddRange(desc2.MainModule.Dependencies); desc1.MainModule.Extensions.AddRange(desc2.MainModule.Extensions); return(desc1); }
static void CollectExtensions (AddinDescription desc, string path, ArrayList extensions) { foreach (Extension ext in desc.MainModule.Extensions) { if (ext.Path == path || path.StartsWith (ext.Path + "/")) extensions.Add (ext); } }
internal static ExtensionNodeDescriptionCollection GetExtensionNodes (AddinRegistry registry, AddinDescription desc, string path) { ArrayList extensions = new ArrayList (); CollectExtensions (desc, path, extensions); foreach (Dependency dep in desc.MainModule.Dependencies) { AddinDependency adep = dep as AddinDependency; if (adep == null) continue; Addin addin = registry.GetAddin (adep.FullAddinId); if (addin != null) CollectExtensions (addin.Description, path, extensions); } // Sort the extensions, to make sure they are added in the correct order // That is, deepest children last. extensions.Sort (new ExtensionComparer ()); ExtensionNodeDescriptionCollection nodes = new ExtensionNodeDescriptionCollection (); // Add the nodes foreach (Extension ext in extensions) { string subp = path.Substring (ext.Path.Length); ExtensionNodeDescriptionCollection col = ext.ExtensionNodes; foreach (string p in subp.Split ('/')) { if (p.Length == 0) continue; ExtensionNodeDescription node = col [p]; if (node == null) { col = null; break; } else col = node.ChildNodes; } if (col != null) nodes.AddRange (col); } return nodes; }
void SyncRoot () { if (CachedAddinManifest.IsRoot != isRoot) { isRoot = CachedAddinManifest.IsRoot; registry = null; manifest = null; } }
public void NotifyChanged (bool externalChange) { if (externalChange) { manifest = null; SyncRoot (); SyncReferences (); } if (Changed != null) Changed (this, EventArgs.Empty); }
public AddinPropertyCollectionImpl(AddinDescription desc) { this.desc = desc; }
public static AddinDescription Read (Stream stream, string basePath) { AddinDescription config = new AddinDescription (); try { config.configDoc = new XmlDocument (); config.configDoc.Load (stream); } catch (Exception ex) { throw new InvalidOperationException ("The add-in configuration file is invalid: " + ex.Message, ex); } XmlElement elem = config.configDoc.DocumentElement; config.id = elem.GetAttribute ("id"); config.ns = elem.GetAttribute ("namespace"); config.name = elem.GetAttribute ("name"); config.version = elem.GetAttribute ("version"); config.compatVersion = elem.GetAttribute ("compatVersion"); config.author = elem.GetAttribute ("author"); config.url = elem.GetAttribute ("url"); config.copyright = elem.GetAttribute ("copyright"); config.description = elem.GetAttribute ("description"); config.category = elem.GetAttribute ("category"); config.basePath = elem.GetAttribute ("basePath"); string s = elem.GetAttribute ("isRoot"); if (s.Length == 0) s = elem.GetAttribute ("isroot"); config.isroot = s == "true" || s == "yes"; s = elem.GetAttribute ("defaultEnabled"); config.defaultEnabled = s.Length == 0 || s == "true" || s == "yes"; XmlElement localizerElem = (XmlElement) elem.SelectSingleNode ("Localizer"); if (localizerElem != null) config.localizer = new ExtensionNodeDescription (localizerElem); if (config.id.Length > 0) config.hasUserId = true; return config; }
/// <summary> /// Load an add-in description from a text reader /// </summary> /// <param name='reader'> /// The text reader /// </param> /// <param name='basePath'> /// The path to be used to resolve relative file paths. /// </param> public static AddinDescription Read(TextReader reader, string basePath) { AddinDescription config = new AddinDescription(); try { config.configDoc = new XmlDocument(); config.configDoc.Load(reader); } catch (Exception ex) { throw new InvalidOperationException("The add-in configuration file is invalid: " + ex.Message, ex); } XmlElement elem = config.configDoc.DocumentElement; if (elem.LocalName == "ExtensionModel") { return(config); } config.id = elem.GetAttribute("id"); config.ns = elem.GetAttribute("namespace"); config.name = elem.GetAttribute("name"); config.version = elem.GetAttribute("version"); config.compatVersion = elem.GetAttribute("compatVersion"); config.author = elem.GetAttribute("author"); config.url = elem.GetAttribute("url"); config.copyright = elem.GetAttribute("copyright"); config.description = elem.GetAttribute("description"); config.category = elem.GetAttribute("category"); config.basePath = elem.GetAttribute("basePath"); config.domain = "global"; string s = elem.GetAttribute("isRoot"); if (s.Length == 0) { s = elem.GetAttribute("isroot"); } config.isroot = GetBool(s, false); config.defaultEnabled = GetBool(elem.GetAttribute("defaultEnabled"), true); string prot = elem.GetAttribute("flags"); if (prot.Length == 0) { config.flags = AddinFlags.None; } else { config.flags = (AddinFlags)Enum.Parse(typeof(AddinFlags), prot); } XmlElement localizerElem = (XmlElement)elem.SelectSingleNode("Localizer"); if (localizerElem != null) { config.localizer = new ExtensionNodeDescription(localizerElem); } XmlElement headerElem = (XmlElement)elem.SelectSingleNode("Header"); if (headerElem != null) { foreach (XmlNode node in headerElem.ChildNodes) { XmlElement prop = node as XmlElement; if (prop == null) { continue; } config.Properties.SetPropertyValue(prop.LocalName, prop.InnerText, prop.GetAttribute("locale")); } } config.TransferCoreProperties(false); if (config.id.Length > 0) { config.hasUserId = true; } return(config); }
public bool GetAddinDescription (IProgressStatus monitor, string addinId, out AddinDescription description) { string file = GetDescriptionPath (addinId); return ReadAddinDescription (monitor, file, out description); }
public static AddinDescription Read (Stream stream, string basePath) { AddinDescription config = new AddinDescription (); try { config.configDoc = new XmlDocument (); config.configDoc.Load (stream); } catch (Exception ex) { throw new InvalidOperationException ("The add-in configuration file is invalid.", ex); } XmlElement elem = config.configDoc.DocumentElement; config.id = elem.GetAttribute ("id"); config.ns = elem.GetAttribute ("namespace"); config.name = elem.GetAttribute ("name"); config.version = elem.GetAttribute ("version"); config.compatVersion = elem.GetAttribute ("compatVersion"); config.author = elem.GetAttribute ("author"); config.url = elem.GetAttribute ("url"); config.copyright = elem.GetAttribute ("copyright"); config.description = elem.GetAttribute ("description"); config.category = elem.GetAttribute ("category"); config.basePath = elem.GetAttribute ("basePath"); config.isroot = elem.GetAttribute ("isroot") == "true" || elem.GetAttribute ("isroot") == "yes"; return config; }
internal void MergeExternalData (AddinDescription other) { // Removes extension types and extension sets coming from other add-ins. foreach (ExtensionPoint ep in other.ExtensionPoints) { ExtensionPoint tep = ExtensionPoints [ep.Path]; if (tep != null) tep.MergeWith (AddinId, ep); } foreach (ExtensionNodeSet ns in other.ExtensionNodeSets) { ExtensionNodeSet tns = ExtensionNodeSets [ns.Id]; if (tns != null) tns.MergeWith (AddinId, ns); } }
public bool ReadAddinDescription (IProgressStatus monitor, string file, out AddinDescription description) { try { description = AddinDescription.ReadBinary (fileDatabase, file); if (description != null) description.OwnerDatabase = this; return true; } catch (Exception ex) { if (monitor == null) throw; description = null; monitor.ReportError ("Could not read folder info file", ex); return false; } }
internal static AddinInfo ReadFromDescription(AddinDescription description) { AddinInfo info = new AddinInfo (); info.id = description.LocalId; info.namspace = description.Namespace; info.name = description.Name; info.version = description.Version; info.author = description.Author; info.copyright = description.Copyright; info.url = description.Url; info.description = description.Description; info.category = description.Category; info.baseVersion = description.CompatVersion; foreach (Dependency dep in description.MainModule.Dependencies) info.Dependencies.Add (dep); foreach (ModuleDescription mod in description.OptionalModules) { foreach (Dependency dep in mod.Dependencies) info.OptionalDependencies.Add (dep); } return info; }
void AddChildExtensions (AddinDescription conf, ModuleDescription module, AddinUpdateData updateData, string path, ExtensionNodeDescriptionCollection nodes, bool conditionChildren) { // Don't register conditions as extension nodes. if (!conditionChildren) updateData.RegisterExtension (conf, module, path); foreach (ExtensionNodeDescription node in nodes) { if (node.NodeName == "ComplexCondition") continue; relExtensionNodes++; string id = node.GetAttribute ("id"); if (id.Length != 0) AddChildExtensions (conf, module, updateData, path + "/" + id, node.ChildNodes, node.NodeName == "Condition"); } }
// Collects extension data in a hash table. The key is the path, the value is a list // of add-ins ids that extend that path void CollectExtensionData (AddinDescription conf, AddinUpdateData updateData) { foreach (ExtensionNodeSet nset in conf.ExtensionNodeSets) { try { updateData.RegisterNodeSet (conf, nset); relNodeSetTypes++; } catch (Exception ex) { throw new InvalidOperationException ("Error reading node set: " + nset.Id, ex); } } foreach (ExtensionPoint ep in conf.ExtensionPoints) { try { updateData.RegisterExtensionPoint (conf, ep); relExtensionPoints++; } catch (Exception ex) { throw new InvalidOperationException ("Error reading extension point: " + ep.Path, ex); } } foreach (ModuleDescription module in conf.AllModules) { foreach (Extension ext in module.Extensions) { relExtensions++; updateData.RegisterExtension (conf, module, ext); AddChildExtensions (conf, module, updateData, ext.Path, ext.ExtensionNodes, false); } } }
public bool SaveDescription (IProgressStatus monitor, AddinDescription desc, string replaceFileName) { try { if (replaceFileName != null) desc.SaveBinary (fileDatabase, replaceFileName); else if (desc.IsRoot) desc.SaveHostBinary (fileDatabase, AddinCachePath); else desc.SaveBinary (fileDatabase, GetDescriptionPath (desc.AddinId)); return true; } catch (Exception ex) { monitor.ReportError ("Add-in info file could not be saved", ex); return false; } }