internal void RegisterAssemblies(RuntimeAddin addin) { foreach (Assembly asm in addin.Assemblies) { loadedAssemblies [asm] = addin; } }
public AnimatedIcon (RuntimeAddin addin, string animationSpec, Gtk.IconSize size) { this.addin = addin; this.size = size; this.animationSpec = animationSpec; Parse (animationSpec); }
RuntimeAddin[] GetDepAddins() { if (depAddins != null) { return(depAddins); } ArrayList plugList = new ArrayList(); string ns = ainfo.Description.Namespace; // Collect dependent ids foreach (Dependency dep in module.Dependencies) { AddinDependency pdep = dep as AddinDependency; if (pdep != null) { RuntimeAddin adn = addinEngine.GetAddin(Addin.GetFullId(ns, pdep.AddinId, pdep.Version)); if (adn != null) { plugList.Add(adn); } else { addinEngine.ReportError("Add-in dependency not loaded: " + pdep.FullAddinId, module.ParentAddinDescription.AddinId, null, false); } } } return(depAddins = (RuntimeAddin[])plugList.ToArray(typeof(RuntimeAddin))); }
internal void UnloadAddin(string id) { RemoveAddinExtensions(id); RuntimeAddin addin = GetAddin(id); if (addin != null) { addin.UnloadExtensions(); lock (LocalLock) { var loadedAddinsCopy = new Dictionary <string, RuntimeAddin> (loadedAddins); loadedAddinsCopy.Remove(Addin.GetIdName(id)); loadedAddins = loadedAddinsCopy; if (addin.AssembliesLoaded) { var loadedAssembliesCopy = new Dictionary <Assembly, RuntimeAddin> (); foreach (Assembly asm in addin.Assemblies) { loadedAssembliesCopy.Remove(asm); } loadedAssemblies = loadedAssembliesCopy; } } ReportAddinUnload(id); } }
protected SolutionItemDescriptor(RuntimeAddin addin, XmlElement element) { this.addin = addin; name = element.GetAttribute ("name"); // relativePath = element.GetAttribute ("directory"); typeName = element.GetAttribute ("type"); template = element; }
public PropertyRef (RuntimeAddin addin, string targetType, string name, string propertyType, bool isExternal, bool skipEmpty) { this.Addin = addin; this.TargetType = targetType; this.Name = name; this.PropertyType = propertyType; this.IsExternal = isExternal; this.SkipEmpty = skipEmpty; }
internal void RegisterAssemblies(RuntimeAddin addin) { lock (LocalLock) { var loadedAssembliesCopy = new Dictionary <Assembly, RuntimeAddin> (loadedAssemblies); foreach (Assembly asm in addin.Assemblies) { loadedAssembliesCopy [asm] = addin; } loadedAssemblies = loadedAssembliesCopy; } }
internal RuntimeAddin(AddinEngine addinEngine, RuntimeAddin parentAddin, ModuleDescription module) { this.addinEngine = addinEngine; this.parentAddin = parentAddin; this.module = module; id = parentAddin.id; baseDirectory = parentAddin.baseDirectory; privatePath = parentAddin.privatePath; ainfo = parentAddin.ainfo; localizer = parentAddin.localizer; module.RuntimeAddin = this; }
internal void InsertExtensionPoint(RuntimeAddin addin, ExtensionPoint ep) { CreateExtensionPoint(ep); foreach (ExtensionNodeType nt in ep.NodeSet.NodeTypes) { if (nt.ObjectTypeName.Length > 0) { Type ntype = addin.GetType(nt.ObjectTypeName, true); RegisterAutoTypeExtensionPoint(ntype, ep.Path); } } }
void LoadModule(ModuleDescription module, string ns, ArrayList plugList, ArrayList asmList) { // Load the assemblies foreach (string s in module.Assemblies) { Assembly asm = null; // don't load the assembly if it's already loaded string asmPath = Path.Combine(baseDirectory, s); foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) { // Sorry, you can't load addins from // dynamic assemblies as get_Location // throws a NotSupportedException if (a is System.Reflection.Emit.AssemblyBuilder) { continue; } if (a.Location == asmPath) { asm = a; break; } } if (asm == null) { asm = Assembly.LoadFrom(asmPath); } asmList.Add(asm); } // Collect dependent ids foreach (Dependency dep in module.Dependencies) { AddinDependency pdep = dep as AddinDependency; if (pdep != null) { RuntimeAddin adn = AddinManager.SessionService.GetAddin(Addin.GetFullId(ns, pdep.AddinId, pdep.Version)); if (adn != null) { plugList.Add(adn); } else { AddinManager.ReportError("Add-in dependency not loaded: " + pdep.FullAddinId, module.ParentAddinDescription.AddinId, null, false); } } } }
public IAddinLocalizer CreateLocalizer (RuntimeAddin addin, NodeElement element) { string pkg = element.GetAttribute ("catalog"); if (pkg.Length == 0) pkg = addin.Id; string dir = element.GetAttribute ("location"); if (dir.Length == 0) dir = "locale"; dir = addin.GetFilePath (dir); domain = new GettextDomain (); domain.Init (pkg, dir); return this; }
internal void UnloadAddin(string id) { defaultContext.RemoveAddinExtensions(id); RuntimeAddin addin = GetAddin(id); if (addin != null) { addin.UnloadExtensions(); loadedAddins.Remove(Addin.GetIdName(id)); AddinManager.ReportAddinUnload(id); } }
bool InsertAddin(IProgressStatus statusMonitor, Addin iad) { try { RuntimeAddin p = new RuntimeAddin(); // Read the config file and load the add-in assemblies AddinDescription description = p.Load(iad); // Register the add-in loadedAddins [Addin.GetIdName(p.Id)] = p; if (!AddinDatabase.RunningSetupProcess) { // Load the extension points and other addin data foreach (ExtensionNodeSet rel in description.ExtensionNodeSets) { RegisterNodeSet(rel); } foreach (ConditionTypeDescription cond in description.ConditionTypes) { Type ctype = p.GetType(cond.TypeName, true); defaultContext.RegisterCondition(cond.Id, ctype); } } foreach (ExtensionPoint ep in description.ExtensionPoints) { InsertExtensionPoint(p, ep); } foreach (Assembly asm in p.Assemblies) { loadedAssemblies [asm] = p; } // Fire loaded event defaultContext.NotifyAddinLoaded(p); AddinManager.ReportAddinLoad(p.Id); return(true); } catch (Exception ex) { AddinManager.ReportError("Extension could not be loaded", iad.Id, ex, false); if (statusMonitor != null) { statusMonitor.ReportError("Extension '" + iad.Id + "' could not be loaded.", ex); } return(false); } }
public void NotifyAddinLoaded(RuntimeAddin ad, bool recursive) { if (extensionNode != null && extensionNode.AddinId == ad.Addin.Id) { extensionNode.OnAddinLoaded(); } if (recursive && childrenLoaded) { foreach (TreeNode node in Children.Clone()) { node.NotifyAddinLoaded(ad, true); } } }
ExtensionLoadData GetAddinExtensions(string id, ExtensionPoint ep) { Addin pinfo = null; // Root add-ins are not returned by GetInstalledAddin. RuntimeAddin addin = AddinManager.SessionService.GetAddin(id); if (addin != null) { pinfo = addin.Addin; } else { pinfo = AddinManager.Registry.GetAddin(id); } if (pinfo == null) { AddinManager.ReportError("Required add-in not found", id, null, false); return(null); } if (!pinfo.Enabled) { return(null); } // Loads extensions defined in each module ExtensionLoadData data = null; AddinDescription conf = pinfo.Description; GetAddinExtensions(conf.MainModule, id, ep, ref data); foreach (ModuleDescription module in conf.OptionalModules) { if (CheckOptionalAddinDependencies(conf, module)) { GetAddinExtensions(module, id, ep, ref data); } } if (data != null) { data.Extensions.Sort(); } return(data); }
internal void UnloadAddin(string id) { defaultContext.RemoveAddinExtensions(id); RuntimeAddin addin = GetAddin(id); if (addin != null) { addin.UnloadExtensions(); loadedAddins.Remove(Addin.GetIdName(id)); foreach (Assembly asm in addin.Assemblies) { loadedAssemblies.Remove(asm); } AddinManager.ReportAddinUnload(id); } }
internal RuntimeAddin GetModule(ModuleDescription module) { // If requesting the root module, return this if (module == module.ParentAddinDescription.MainModule) { return(this); } if (module.RuntimeAddin != null) { return(module.RuntimeAddin); } RuntimeAddin addin = new RuntimeAddin(addinEngine, this, module); return(addin); }
bool InsertAddin(IProgressStatus statusMonitor, Addin iad) { try { RuntimeAddin p = new RuntimeAddin(this); // Read the config file and load the add-in assemblies AddinDescription description = p.Load(iad); // Register the add-in var loadedAddinsCopy = new Dictionary <string, RuntimeAddin> (loadedAddins); loadedAddinsCopy [Addin.GetIdName(p.Id)] = p; loadedAddins = loadedAddinsCopy; if (!AddinDatabase.RunningSetupProcess) { // Load the extension points and other addin data RegisterNodeSets(iad.Id, description.ExtensionNodeSets); foreach (ConditionTypeDescription cond in description.ConditionTypes) { Type ctype = p.GetType(cond.TypeName, true); RegisterCondition(cond.Id, ctype); } } foreach (ExtensionPoint ep in description.ExtensionPoints) { InsertExtensionPoint(p, ep); } // Fire loaded event NotifyAddinLoaded(p); ReportAddinLoad(p.Id); return(true); } catch (Exception ex) { ReportError("Add-in could not be loaded", iad.Id, ex, false); if (statusMonitor != null) { statusMonitor.ReportError("Add-in '" + iad.Id + "' could not be loaded.", ex); } return(false); } }
internal void NotifyAddinLoaded(RuntimeAddin ad) { tree.NotifyAddinLoaded(ad, true); lock (conditionTypes) { if (childContexts != null) { foreach (WeakReference wref in childContexts) { ExtensionContext ctx = wref.Target as ExtensionContext; if (ctx != null) { ctx.NotifyAddinLoaded(ad); } } } } }
public void ResetCachedData() { if (extensionPoint != null) { string aid = Addin.GetIdName(extensionPoint.ParentAddinDescription.AddinId); RuntimeAddin ad = AddinManager.SessionService.GetAddin(aid); if (ad != null) { extensionPoint = ad.Addin.Description.ExtensionPoints [GetPath()]; } } if (childrenList != null) { foreach (TreeNode cn in childrenList) { cn.ResetCachedData(); } } }
void LoadModuleExtensionNodes(Extension extension, string addinId, ExtensionNodeSet nset, ArrayList loadedNodes) { // Now load the extensions ArrayList addedNodes = new ArrayList(); tree.LoadExtension(addinId, extension, addedNodes); RuntimeAddin ad = AddinManager.SessionService.GetAddin(addinId); if (ad != null) { foreach (TreeNode nod in addedNodes) { // Don't call OnAddinLoaded here. Do it when the entire extension point has been loaded. if (nod.ExtensionNode != null) { loadedNodes.Add(nod); } } } }
public static SolutionDescriptor CreateSolutionDescriptor (RuntimeAddin addin, XmlElement xmlElement, FilePath baseDirectory) { SolutionDescriptor solutionDescriptor = new SolutionDescriptor (); solutionDescriptor.addin = addin; if (xmlElement.Attributes["name"] != null) solutionDescriptor.name = xmlElement.Attributes["name"].Value; else throw new InvalidOperationException ("Attribute 'name' not found"); if (xmlElement.Attributes["type"] != null) solutionDescriptor.type = xmlElement.Attributes["type"].Value; if (xmlElement.Attributes["directory"] != null) solutionDescriptor.directory = xmlElement.Attributes["directory"].Value; if (xmlElement["Options"] != null && xmlElement["Options"]["StartupProject"] != null) solutionDescriptor.startupProject = xmlElement["Options"]["StartupProject"].InnerText; foreach (XmlNode xmlNode in xmlElement.ChildNodes) { if (xmlNode is XmlElement) { XmlElement xmlNodeElement = (XmlElement)xmlNode; switch (xmlNodeElement.Name) { case "Project": solutionDescriptor.entryDescriptors.Add ( ProjectDescriptor.CreateProjectDescriptor (xmlNodeElement, baseDirectory)); break; case "CombineEntry": case "SolutionItem": solutionDescriptor.entryDescriptors.Add ( SolutionItemDescriptor.CreateDescriptor (addin, xmlNodeElement)); break; } } } return solutionDescriptor; }
public bool FindExtensionPathByType(IProgressStatus monitor, Type type, string nodeName, out string path, out string pathNodeName) { if (extensionPoint != null) { foreach (ExtensionNodeType nt in extensionPoint.NodeSet.NodeTypes) { if (nt.ObjectTypeName.Length > 0 && (nodeName.Length == 0 || nodeName == nt.Id)) { RuntimeAddin addin = AddinManager.SessionService.GetAddin(extensionPoint.RootAddin); Type ot = addin.GetType(nt.ObjectTypeName); if (ot != null) { if (ot.IsAssignableFrom(type)) { path = extensionPoint.Path; pathNodeName = nt.Id; return(true); } } else { monitor.ReportError("Type '" + nt.ObjectTypeName + "' not found in add-in '" + Id + "'", null); } } } } else { foreach (TreeNode node in Children) { if (node.FindExtensionPathByType(monitor, type, nodeName, out path, out pathNodeName)) { return(true); } } } path = null; pathNodeName = null; return(false); }
public IAddinLocalizer CreateLocalizer (RuntimeAddin addin, NodeElement element) { foreach (NodeElement nloc in element.ChildNodes) { if (nloc.NodeName != "Locale") throw new InvalidOperationException ("Invalid element found: '" + nloc.NodeName + "'. Expected: 'Locale'"); string ln = nloc.GetAttribute ("id"); if (ln.Length == 0) throw new InvalidOperationException ("Locale id not specified"); ln = ln.Replace ('_','-'); Hashtable messages = new Hashtable (); foreach (NodeElement nmsg in nloc.ChildNodes) { if (nmsg.NodeName != "Msg") throw new InvalidOperationException ("Locale '" + ln + "': Invalid element found: '" + nmsg.NodeName + "'. Expected: 'Msg'"); string id = nmsg.GetAttribute ("id"); if (id.Length == 0) throw new InvalidOperationException ("Locale '" + ln + "': Message id not specified"); messages [id] = nmsg.GetAttribute ("str"); } locales [ln] = messages; } return this; }
static int GetAddinId (RuntimeAddin addin) { int result = addins.IndexOf (addin); if (result == -1) { result = addins.Count; addinIcons.Add (new Dictionary<string, string> ()); } return result; }
static string InternalGetStockIdFromResource (RuntimeAddin addin, string id, Gtk.IconSize size) { if (!id.StartsWith ("res:", StringComparison.Ordinal)) return id; id = id.Substring (4); int addinId = GetAddinId (addin); Dictionary<string, string> hash = addinIcons[addinId]; string stockId = "__asm" + addinId + "__" + id + "__" + size; if (!hash.ContainsKey (stockId)) { System.IO.Stream stream = addin.GetResource (id); if (stream != null) { Gdk.Pixbuf pix1, pix2 = null; using (stream) { pix1 = new Gdk.Pixbuf (stream); } stream = addin.GetResource2x (id); if (stream != null) { using (stream) { pix2 = new Gdk.Pixbuf (stream); } } AddToIconFactory (stockId, pix1, pix2, size); } hash[stockId] = stockId; } return stockId; }
static string InternalGetStockIdFromAnimation (RuntimeAddin addin, string id, Gtk.IconSize size) { if (!id.StartsWith ("animation:")) return id; id = id.Substring (10); Dictionary<string, string> hash; int addinId; if (addin != null) { addinId = GetAddinId (addin); hash = addinIcons[addinId]; } else { addinId = -1; hash = iconSpecToStockId; } string stockId = "__asm" + addinId + "__" + id + "__" + size; if (!hash.ContainsKey (stockId)) { var aicon = new AnimatedIcon (addin, id, size); AddToIconFactory (stockId, aicon.FirstFrame.WithSize (size).ToPixbuf (), null, size); AddToAnimatedIconFactory (stockId, aicon); hash[stockId] = stockId; } return stockId; }
public static string GetStockId (RuntimeAddin addin, string filename) { return GetStockId (addin, filename, Gtk.IconSize.Invalid); }
public static string GetStockId (RuntimeAddin addin, string filename, Gtk.IconSize iconSize) { return GetStockIdForImageSpec (addin, filename, iconSize); }
internal void RegisterAssemblies(RuntimeAddin addin) { foreach (Assembly asm in addin.Assemblies) loadedAssemblies [asm] = addin; }
internal static string GetStockId (RuntimeAddin addin, string icon) { return icon; }
bool InitializeNodeType(ExtensionNodeType ntype) { RuntimeAddin p = addinEngine.GetAddin(ntype.AddinId); if (p == null) { if (!addinEngine.IsAddinLoaded(ntype.AddinId)) { if (!addinEngine.LoadAddin(null, ntype.AddinId, false)) { return(false); } p = addinEngine.GetAddin(ntype.AddinId); if (p == null) { addinEngine.ReportError("Add-in not found", ntype.AddinId, null, false); return(false); } } } // If no type name is provided, use TypeExtensionNode by default if (ntype.TypeName == null || ntype.TypeName.Length == 0 || ntype.TypeName == typeof(TypeExtensionNode).FullName) { // If it has a custom attribute, use the generic version of TypeExtensionNode if (ntype.ExtensionAttributeTypeName.Length > 0) { Type attType = p.GetType(ntype.ExtensionAttributeTypeName, false); if (attType == null) { addinEngine.ReportError("Custom attribute type '" + ntype.ExtensionAttributeTypeName + "' not found.", ntype.AddinId, null, false); return(false); } if (ntype.ObjectTypeName.Length > 0 || ntype.TypeName == typeof(TypeExtensionNode).FullName) { ntype.Type = typeof(TypeExtensionNode <>).MakeGenericType(attType); } else { ntype.Type = typeof(ExtensionNode <>).MakeGenericType(attType); } } else { ntype.Type = typeof(TypeExtensionNode); return(true); } } else { ntype.Type = p.GetType(ntype.TypeName, false); if (ntype.Type == null) { addinEngine.ReportError("Extension node type '" + ntype.TypeName + "' not found.", ntype.AddinId, null, false); return(false); } } // Check if the type has NodeAttribute attributes applied to fields. ExtensionNodeType.FieldData boundAttributeType = null; Dictionary <string, ExtensionNodeType.FieldData> fields = GetMembersMap(ntype.Type, out boundAttributeType); ntype.CustomAttributeMember = boundAttributeType; if (fields.Count > 0) { ntype.Fields = fields; } // If the node type is bound to a custom attribute and there is a member bound to that attribute, // get the member map for the attribute. if (boundAttributeType != null) { if (ntype.ExtensionAttributeTypeName.Length == 0) { throw new InvalidOperationException("Extension node not bound to a custom attribute."); } if (ntype.ExtensionAttributeTypeName != boundAttributeType.MemberType.FullName) { throw new InvalidOperationException("Incorrect custom attribute type declaration in " + ntype.Type + ". Expected '" + ntype.ExtensionAttributeTypeName + "' found '" + boundAttributeType.MemberType.FullName + "'"); } fields = GetMembersMap(boundAttributeType.MemberType, out boundAttributeType); if (fields.Count > 0) { ntype.CustomAttributeFields = fields; } } return(true); }
bool InitializeNodeType(ExtensionNodeType ntype) { RuntimeAddin p = AddinManager.SessionService.GetAddin(ntype.AddinId); if (p == null) { if (!AddinManager.SessionService.IsAddinLoaded(ntype.AddinId)) { if (!AddinManager.SessionService.LoadAddin(null, ntype.AddinId, false)) { return(false); } p = AddinManager.SessionService.GetAddin(ntype.AddinId); if (p == null) { AddinManager.ReportError("Add-in not found", ntype.AddinId, null, false); return(false); } } } // If no type name is provided, use TypeExtensionNode by default if (ntype.TypeName == null || ntype.TypeName.Length == 0) { ntype.Type = typeof(TypeExtensionNode); return(true); } ntype.Type = p.GetType(ntype.TypeName, false); if (ntype.Type == null) { AddinManager.ReportError("Extension node type '" + ntype.TypeName + "' not found.", ntype.AddinId, null, false); return(false); } Hashtable fields = new Hashtable(); // Check if the type has NodeAttribute attributes applied to fields. Type type = ntype.Type; while (type != typeof(object) && type != null) { foreach (FieldInfo field in type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { NodeAttributeAttribute at = (NodeAttributeAttribute)Attribute.GetCustomAttribute(field, typeof(NodeAttributeAttribute), true); if (at != null) { ExtensionNodeType.FieldData fdata = new ExtensionNodeType.FieldData(); fdata.Field = field; fdata.Required = at.Required; fdata.Localizable = at.Localizable; string name; if (at.Name != null && at.Name.Length > 0) { name = at.Name; } else { name = field.Name; } fields [name] = fdata; } } type = type.BaseType; } if (fields.Count > 0) { ntype.Fields = fields; } return(true); }
public static SolutionItemDescriptor CreateDescriptor(RuntimeAddin addin, XmlElement element) { return new SolutionItemDescriptor (addin, element); }
static string GetStockIdForImageSpec (RuntimeAddin addin, string filename, Gtk.IconSize size) { if (filename.IndexOf ('|') == -1) return PrivGetStockId (addin, filename, size); string[] parts = filename.Split ('|'); for (int n = 0; n < parts.Length; n++) { parts[n] = PrivGetStockId (addin, parts[n], size); } return GetComposedIcon (parts, size); }
internal RuntimeAddin GetModule(ModuleDescription module) { // If requesting the root module, return this if (module == module.ParentAddinDescription.MainModule) return this; if (module.RuntimeAddin != null) return module.RuntimeAddin; RuntimeAddin addin = new RuntimeAddin (addinEngine, this, module); return addin; }
protected ProjectTemplate (RuntimeAddin addin, string id, ProjectTemplateCodon codon, string overrideLanguage) { XmlDocument xmlDocument = codon.GetTemplate (); XmlElement xmlConfiguration = xmlDocument.DocumentElement ["TemplateConfiguration"]; // Get legacy category. if (xmlConfiguration ["_Category"] != null) { category = xmlConfiguration ["_Category"].InnerText; } if (xmlConfiguration ["Category"] != null) { category = xmlConfiguration ["Category"].InnerText; } else if (category == null) { LoggingService.LogWarning (string.Format ("Category missing in project template {0}", codon.Id)); } if (!string.IsNullOrEmpty (overrideLanguage)) { this.languagename = overrideLanguage; this.category = overrideLanguage + "/" + this.category; } else if (xmlConfiguration ["LanguageName"] != null) { List<string> listLanguages = new List<string> (); foreach (string item in xmlConfiguration ["LanguageName"].InnerText.Split (',')) listLanguages.Add (item.Trim ()); ExpandLanguageWildcards (listLanguages); this.languagename = listLanguages [0]; if (listLanguages.Count > 1 && !String.IsNullOrEmpty (languagename) && !category.StartsWith (languagename + "/")) category = languagename + "/" + category; for (int i = 1; i < listLanguages.Count; i++) { string language = listLanguages[i]; try { ProjectTemplates.Add (new ProjectTemplate (addin, id, codon, language)); } catch (Exception e) { LoggingService.LogError (GettextCatalog.GetString ("Error loading template {0} for language {1}", codon.Id, language), e); } } } this.id = id; this.originator = xmlDocument.DocumentElement.GetAttribute ("originator"); this.created = xmlDocument.DocumentElement.GetAttribute ("created"); this.lastModified = xmlDocument.DocumentElement.GetAttribute ("lastModified"); if (xmlConfiguration ["Wizard"] != null) { this.wizardPath = xmlConfiguration ["Wizard"].InnerText; } if (xmlConfiguration ["_Name"] != null) { this.nonLocalizedName = xmlConfiguration ["_Name"].InnerText; this.name = addin.Localizer.GetString (this.nonLocalizedName); } if (xmlConfiguration ["_Description"] != null) { this.description = addin.Localizer.GetString (xmlConfiguration ["_Description"].InnerText); } if (xmlConfiguration ["Icon"] != null) { this.icon = ImageService.GetStockId (addin, xmlConfiguration ["Icon"].InnerText, Gtk.IconSize.Dnd); } if (xmlConfiguration ["GroupId"] != null) { this.groupId = xmlConfiguration ["GroupId"].InnerText; this.condition = xmlConfiguration ["GroupId"].GetAttribute ("condition"); } if (xmlConfiguration ["FileExtension"] != null) { this.fileExtension = xmlConfiguration ["FileExtension"].InnerText; } if (xmlConfiguration ["SupportedParameters"] != null) { this.supportedParameters = xmlConfiguration ["SupportedParameters"].InnerText; } if (xmlConfiguration ["DefaultParameters"] != null) { this.defaultParameters = xmlConfiguration ["DefaultParameters"].InnerText; } if (xmlConfiguration ["Image"] != null) { XmlElement imageElement = xmlConfiguration ["Image"]; imageId = imageElement.GetAttribute ("id"); imageFile = imageElement.GetAttribute ("file"); if (!String.IsNullOrEmpty (imageFile)) { imageFile = Path.Combine (codon.BaseDirectory, imageFile); } } if (xmlConfiguration ["Visibility"] != null) { visibility = xmlConfiguration ["Visibility"].InnerText; } if (xmlDocument.DocumentElement ["Combine"] == null) { throw new InvalidOperationException ("Combine element not found"); } else { solutionDescriptor = SolutionDescriptor.CreateSolutionDescriptor (addin, xmlDocument.DocumentElement ["Combine"], codon.BaseDirectory); } if (xmlDocument.DocumentElement ["Actions"] != null) { foreach (XmlNode xmlElement in xmlDocument.DocumentElement ["Actions"]) { if (xmlElement is XmlElement && xmlElement.Attributes ["filename"] != null) actions.Add (xmlElement.Attributes ["filename"].Value); } } }
public CustomImageLoader (RuntimeAddin addin) { this.addin = addin; }
public void SetDefaultHandlerTypeInfo (RuntimeAddin addin, string typeName) { defaultHandlerAddin = addin; defaultHandlerTypeName = typeName; }
bool InitializeNodeType(ExtensionNodeType ntype) { RuntimeAddin p = AddinManager.SessionService.GetAddin(ntype.AddinId); if (p == null) { if (!AddinManager.SessionService.IsAddinLoaded(ntype.AddinId)) { if (!AddinManager.SessionService.LoadAddin(null, ntype.AddinId, false)) { return(false); } p = AddinManager.SessionService.GetAddin(ntype.AddinId); if (p == null) { AddinManager.ReportError("Add-in not found", ntype.AddinId, null, false); return(false); } } } // If no type name is provided, use TypeExtensionNode by default if (ntype.TypeName == null || ntype.TypeName.Length == 0) { ntype.Type = typeof(TypeExtensionNode); return(true); } ntype.Type = p.GetType(ntype.TypeName, false); if (ntype.Type == null) { AddinManager.ReportError("Extension node type '" + ntype.TypeName + "' not found.", ntype.AddinId, null, false); return(false); } Hashtable fields = new Hashtable(); ArrayList reqFields = new ArrayList(); // Check if the type has NodeAttribute attributes applied to fields. foreach (FieldInfo field in ntype.Type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { NodeAttributeAttribute at = (NodeAttributeAttribute)Attribute.GetCustomAttribute(field, typeof(NodeAttributeAttribute), true); if (at != null) { string name; if (at.Name != null && at.Name.Length > 0) { name = at.Name; } else { name = field.Name; } if (at.Required) { reqFields.Add(name); } fields [name] = field; } } if (fields.Count > 0) { ntype.Fields = fields; if (reqFields.Count > 0) { ntype.RequiredFields = (string[])reqFields.ToArray(typeof(string)); } } return(true); }
static string PrivGetStockId (RuntimeAddin addin, string filename, Gtk.IconSize size) { if (addin != null && filename.StartsWith ("res:")) return InternalGetStockIdFromResource (addin, filename, size); if (filename.StartsWith ("animation:")) return InternalGetStockIdFromAnimation (addin, filename, size); return filename; }
static Xwt.Drawing.Image LoadStockIcon (RuntimeAddin addin, string stockId, string resource, string imageFile, string iconId, Gtk.IconSize iconSize, string animation, bool forceWildcard) { try { Gdk.Pixbuf pixbuf = null, pixbuf2x = null; AnimatedIcon animatedIcon = null; Func<Stream[]> imageLoader = null; if (!string.IsNullOrEmpty (resource) || !string.IsNullOrEmpty (imageFile)) { // using the stream directly produces a gdk warning. byte[] buffer; if (resource != null) { imageLoader = delegate { var stream = addin.GetResource (resource); var stream2x = addin.GetResource2x (resource); if (stream2x == null) return new [] { stream }; else return new [] { stream, stream2x }; }; } else { imageLoader = delegate { var file = addin.GetFilePath (imageFile); var stream = File.OpenRead (file); Stream stream2x = null; var file2x = Path.Combine (Path.GetDirectoryName (file), Path.GetFileNameWithoutExtension (file) + "@2x" + Path.GetExtension (file)); if (File.Exists (file2x)) stream2x = File.OpenRead (file2x); else { file2x = file + "@2x"; if (File.Exists (file2x)) stream2x = File.OpenRead (file2x); } if (stream2x == null) return new [] { stream }; else return new [] { stream, stream2x }; }; } var streams = imageLoader (); var st = streams[0]; var st2x = streams.Length > 1 ? streams[1] : null; using (st) { if (st == null || st.Length < 0) { LoggingService.LogError ("Did not find resource '{0}' in addin '{1}' for icon '{2}'", resource, addin.Id, stockId); return null; } buffer = new byte [st.Length]; st.Read (buffer, 0, (int)st.Length); } pixbuf = new Gdk.Pixbuf (buffer); using (st2x) { if (st2x != null && st2x.Length >= 0) { buffer = new byte [st2x.Length]; st2x.Read (buffer, 0, (int)st2x.Length); pixbuf2x = new Gdk.Pixbuf (buffer); } } } else if (!string.IsNullOrEmpty (iconId)) { var id = GetStockIdForImageSpec (addin, iconId, iconSize); pixbuf = GetPixbuf (id, iconSize); pixbuf2x = Get2xIconVariant (pixbuf); // This may be an animation, get it animationFactory.TryGetValue (id, out animatedIcon); } else if (!string.IsNullOrEmpty (animation)) { string id = GetStockIdForImageSpec (addin, "animation:" + animation, iconSize); pixbuf = GetPixbuf (id, iconSize); // This *should* be an animation animationFactory.TryGetValue (id, out animatedIcon); } Gtk.IconSize size = forceWildcard? Gtk.IconSize.Invalid : iconSize; if (pixbuf != null) AddToIconFactory (stockId, pixbuf, pixbuf2x, size); if (animatedIcon != null) AddToAnimatedIconFactory (stockId, animatedIcon); var img = Xwt.Toolkit.CurrentEngine.WrapImage (pixbuf); if (pixbuf2x != null) { var img2x = Xwt.Toolkit.CurrentEngine.WrapImage (pixbuf2x); img = Xwt.Drawing.Image.CreateMultiResolutionImage (new [] { img, img2x }); } if (imageLoader != null) img.SetStreamSource (imageLoader); return img; } catch (Exception ex) { LoggingService.LogError (string.Format ("Error loading icon '{0}'", stockId), ex); return null; } }
internal void RegisterAssemblies (RuntimeAddin addin) { lock (LocalLock) { var loadedAssembliesCopy = new Dictionary<Assembly,RuntimeAddin> (loadedAssemblies); foreach (Assembly asm in addin.Assemblies) loadedAssembliesCopy [asm] = addin; loadedAssemblies = loadedAssembliesCopy; } }
static string InternalGetStockIdFromResource (RuntimeAddin addin, string id, Gtk.IconSize size) { if (!id.StartsWith ("res:", StringComparison.Ordinal)) return id; id = id.Substring (4); int addinId = GetAddinId (addin); Dictionary<string, string> hash = addinIcons[addinId]; string stockId = "__asm" + addinId + "__" + id + "__" + size; if (!hash.ContainsKey (stockId)) { icons[stockId] = LoadStockIcon (addin, stockId, id, null, null, size, null, false); hash[stockId] = stockId; } return stockId; }
private static FileTemplate LoadFileTemplate (RuntimeAddin addin, ProjectTemplateCodon codon) { XmlDocument xmlDocument = codon.GetTemplate (); FilePath baseDirectory = codon.BaseDirectory; //Configuration XmlElement xmlNodeConfig = xmlDocument.DocumentElement["TemplateConfiguration"]; FileTemplate fileTemplate = null; if (xmlNodeConfig["Type"] != null) { Type configType = addin.GetType (xmlNodeConfig["Type"].InnerText); if (typeof (FileTemplate).IsAssignableFrom (configType)) { fileTemplate = (FileTemplate)Activator.CreateInstance (configType); } else throw new InvalidOperationException (string.Format ("The file template class '{0}' must be a subclass of MonoDevelop.Ide.Templates.FileTemplate", xmlNodeConfig["Type"].InnerText)); } else fileTemplate = new FileTemplate (); fileTemplate.originator = xmlDocument.DocumentElement.GetAttribute ("Originator"); fileTemplate.created = xmlDocument.DocumentElement.GetAttribute ("Created"); fileTemplate.lastModified = xmlDocument.DocumentElement.GetAttribute ("LastModified"); if (xmlNodeConfig["_Name"] != null) { fileTemplate.name = xmlNodeConfig["_Name"].InnerText; } else { throw new InvalidOperationException (string.Format ("Missing element '_Name' in file template: {0}", codon.Id)); } if (xmlNodeConfig["_Category"] != null) { fileTemplate.category = xmlNodeConfig["_Category"].InnerText; } else { throw new InvalidOperationException (string.Format ("Missing element '_Category' in file template: {0}", codon.Id)); } if (xmlNodeConfig["LanguageName"] != null) { fileTemplate.languageName = xmlNodeConfig["LanguageName"].InnerText; } if (xmlNodeConfig["ProjectType"] != null) { fileTemplate.projecttype = xmlNodeConfig["ProjectType"].InnerText; } if (xmlNodeConfig["_Description"] != null) { fileTemplate.description = xmlNodeConfig["_Description"].InnerText; } if (xmlNodeConfig["Icon"] != null) { fileTemplate.icon = ImageService.GetStockId (addin, xmlNodeConfig["Icon"].InnerText, IconSize.Dnd); //xmlNodeConfig["_Description"].InnerText; } if (xmlNodeConfig["Wizard"] != null) { fileTemplate.icon = xmlNodeConfig["Wizard"].Attributes["path"].InnerText; } if (xmlNodeConfig["DefaultFilename"] != null) { fileTemplate.defaultFilename = xmlNodeConfig["DefaultFilename"].InnerText; string isFixed = xmlNodeConfig["DefaultFilename"].GetAttribute ("IsFixed"); if (isFixed.Length > 0) { bool bFixed; if (bool.TryParse (isFixed, out bFixed)) fileTemplate.isFixedFilename = bFixed; else throw new InvalidOperationException ("Invalid value for IsFixed in template."); } } //Template files XmlNode xmlNodeTemplates = xmlDocument.DocumentElement["TemplateFiles"]; if(xmlNodeTemplates != null) { foreach(XmlNode xmlNode in xmlNodeTemplates.ChildNodes) { if(xmlNode is XmlElement) { fileTemplate.files.Add ( FileDescriptionTemplate.CreateTemplate ((XmlElement)xmlNode, baseDirectory)); } } } //Conditions XmlNode xmlNodeConditions = xmlDocument.DocumentElement["Conditions"]; if(xmlNodeConditions != null) { foreach(XmlNode xmlNode in xmlNodeConditions.ChildNodes) { if(xmlNode is XmlElement) { fileTemplate.conditions.Add (FileTemplateCondition.CreateCondition ((XmlElement)xmlNode)); } } } return fileTemplate; }
internal void InsertExtensionPoint(RuntimeAddin addin, ExtensionPoint ep) { CreateExtensionPoint (ep); foreach (ExtensionNodeType nt in ep.NodeSet.NodeTypes) { if (nt.ObjectTypeName.Length > 0) { Type ntype = addin.GetType (nt.ObjectTypeName, true); RegisterAutoTypeExtensionPoint (ntype, ep.Path); } } }
bool InsertAddin(IProgressStatus statusMonitor, Addin iad) { try { RuntimeAddin p = new RuntimeAddin (this); // Read the config file and load the add-in assemblies AddinDescription description = p.Load (iad); // Register the add-in loadedAddins [Addin.GetIdName (p.Id)] = p; if (!AddinDatabase.RunningSetupProcess) { // Load the extension points and other addin data foreach (ExtensionNodeSet rel in description.ExtensionNodeSets) { RegisterNodeSet (rel); } foreach (ConditionTypeDescription cond in description.ConditionTypes) { Type ctype = p.GetType (cond.TypeName, true); RegisterCondition (cond.Id, ctype); } } foreach (ExtensionPoint ep in description.ExtensionPoints) InsertExtensionPoint (p, ep); // Fire loaded event NotifyAddinLoaded (p); ReportAddinLoad (p.Id); return true; } catch (Exception ex) { ReportError ("Add-in could not be loaded", iad.Id, ex, false); if (statusMonitor != null) statusMonitor.ReportError ("Add-in '" + iad.Id + "' could not be loaded.", ex); return false; } }
protected ProjectTemplate (RuntimeAddin addin, string id, ProjectTemplateCodon codon) : this (addin, id, codon, null) { }
public IAddinLocalizer CreateLocalizer (RuntimeAddin addin, NodeElement element) { this.addin = addin; return this; }
public static string GetStockId (RuntimeAddin addin, string filename, Gtk.IconSize iconSize) { return InternalGetStockId (addin, filename, iconSize); }