public Resolve ( Mono.Cecil.AssemblyNameReference name ) : |
||
name | Mono.Cecil.AssemblyNameReference | |
return |
TypeDefinition FindTypeDefinition(Hashtable visited, AssemblyResolver resolver, string basePath, AssemblyDefinition asm, string fullName) { if (visited.Contains(asm)) { return(null); } visited [asm] = asm; TypeDefinition cls = asm.MainModule.GetType(fullName); if (cls != null) { return(cls); } foreach (AssemblyNameReference aref in asm.MainModule.AssemblyReferences) { AssemblyDefinition basm = resolver.Resolve(aref, basePath); if (basm != null) { cls = basm.MainModule.GetType(fullName); if (cls != null) { return(cls); } } } return(null); }
public CecilWidgetLibrary(AssemblyResolver resolver, string path) { name = path; this.resolver = resolver; if (System.IO.File.Exists(path)) { filename = path; } else if (resolver != null) { filename = resolver.Resolve(path, null); } if (filename == null) { filename = path; } else { filename = System.IO.Path.GetFullPath(filename); } RefreshFromCache(); }
void ScanLibraries(ArrayList list, Assembly asm) { foreach (AssemblyName aname in asm.GetReferencedAssemblies()) { Assembly depasm = null; try { depasm = Assembly.Load(aname); } catch { } if (depasm == null) { string file = resolver != null?resolver.Resolve(aname.FullName, Path.GetDirectoryName(asm.Location)) : null; if (file != null) { depasm = Assembly.LoadFrom(file); } else { throw new InvalidOperationException("Assembly not found: " + aname.FullName); } } ManifestResourceInfo res = depasm.GetManifestResourceInfo("objects.xml"); if (res != null) { list.Add(depasm.Location); } } }
public AssemblyWidgetLibrary(AssemblyResolver resolver, string assemblyPath) { this.name = assemblyPath; string ares = resolver.Resolve(assemblyPath, null); if (ares != null) { assemblyPath = ares; } this.resolver = resolver; if (assemblyPath.EndsWith(".dll") || assemblyPath.EndsWith(".exe")) { if (File.Exists(assemblyPath)) { assembly = Assembly.LoadFrom(assemblyPath); } } else { assembly = Assembly.Load(assemblyPath); } if (assembly == null) { throw new InvalidOperationException("Couldn't load assembly at " + assemblyPath); } UpdateCache(); }
bool ReferenceChainContainsGtk(AssemblyResolver resolver, AssemblyNameReference aref, Hashtable visited) { if (aref.Name == "gtk-sharp") { return(true); } else if (visited.Contains(aref.Name)) { return(false); } visited [aref.Name] = aref; AssemblyDefinition adef = resolver.Resolve(aref); if (adef == null) { return(false); } foreach (AssemblyNameReference child in adef.MainModule.AssemblyReferences) { if (ReferenceChainContainsGtk(resolver, child, visited)) { return(true); } } return(false); }
AssemblyDefinition ResolveAssembly(AssemblyNameReference aref) { string bpath = Path.Combine(Path.GetDirectoryName(filename), aref.Name); string filePath = null; if (resolver != null) { filePath = resolver.Resolve(aref.FullName, null); } if (filePath != null) { if (File.Exists(bpath + ".dll")) { filePath = bpath + ".dll"; } if (File.Exists(bpath + ".exe")) { filePath = bpath + ".exe"; } } AssemblyDefinition adef = null; if (filePath != null) { adef = AssemblyFactory.GetAssembly(filePath); } else { try { adef = resolver.Resolve(aref); } catch { // If can't resolve, just return null return(null); } } return(adef); }
void LoadLibraries(AssemblyResolver resolver, Hashtable visited, IEnumerable libraries) { // Convert all assembly names to assembly paths before registering the libraries. // The registry and the library cache will only handle full paths. foreach (string s in libraries) { string sr = resolver.Resolve(s, null); if (sr != null) { AddLibrary(resolver, visited, sr); } } Registry.ReloadWidgetLibraries(); }
public CecilWidgetLibrary(AssemblyResolver resolver, string path) { name = path; this.resolver = resolver; cache.Refresh (resolver, name); if (resolver != null) filename = resolver.Resolve (path, null); if (filename == null) filename = path; assembly = AssemblyFactory.GetAssembly (filename); }
public CecilWidgetLibrary (AssemblyResolver resolver, string path) { name = path; this.resolver = resolver; if (System.IO.File.Exists (path)) filename = path; else if (resolver != null) filename = resolver.Resolve (path, null); if (filename == null) filename = path; else filename = System.IO.Path.GetFullPath (filename); RefreshFromCache (); }
void AddDependencies(XmlElement elem, AssemblyResolver resolver, string filename, AssemblyDefinition asm) { string dir = Path.GetDirectoryName(filename); foreach (AssemblyNameReference aref in asm.MainModule.AssemblyReferences) { string file = null; if (resolver != null) { resolver.Resolve(aref.FullName, dir); } if (file != null && Application.InternalIsWidgetLibrary(resolver, file)) { XmlElement edep = elem.OwnerDocument.CreateElement("dependency"); edep.InnerText = file; elem.AppendChild(edep); } } }
public CecilWidgetLibrary(AssemblyResolver resolver, string path) { name = path; this.resolver = resolver; cache.Refresh(resolver, name); if (resolver != null) { filename = resolver.Resolve(path, null); } if (filename == null) { filename = path; } assembly = AssemblyFactory.GetAssembly(filename); }
public AssemblyWidgetLibrary (AssemblyResolver resolver, string assemblyPath) { this.name = assemblyPath; string ares = resolver.Resolve (assemblyPath, null); if (ares != null) assemblyPath = ares; this.resolver = resolver; if (assemblyPath.EndsWith (".dll") || assemblyPath.EndsWith (".exe")) { if (File.Exists (assemblyPath)) assembly = Assembly.LoadFrom (assemblyPath); } else assembly = Assembly.Load (assemblyPath); if (assembly == null) throw new InvalidOperationException ("Couldn't load assembly at " + assemblyPath); UpdateCache (); }
internal static bool InternalIsWidgetLibrary(AssemblyResolver resolver, string assemblyRef) { string path; if (assemblyRef.EndsWith(".dll") || assemblyRef.EndsWith(".exe")) { if (!File.Exists(assemblyRef)) { return(false); } path = assemblyRef; } else { path = resolver.Resolve(assemblyRef, null); if (path == null) { return(false); } } return(CecilWidgetLibrary.IsWidgetLibrary(path)); }
ToolboxItemInfo GetToolboxItemInfo(AssemblyResolver resolver, TypeDefinition tdef) { if (tdef == null) { return(null); } ToolboxItemInfo info = null; string category = "General"; foreach (CustomAttribute attr in tdef.CustomAttributes) { switch (attr.Constructor.DeclaringType.FullName) { case "System.ComponentModel.ToolboxItemAttribute": attr.Resolve(); if (attr.ConstructorParameters.Count > 0) { object param = attr.ConstructorParameters [0]; if (param == null) { return(null); } else if (param.GetType() == typeof(bool)) { if ((bool)param) { info = new ToolboxItemInfo("Gtk.Widget"); } else { return(null); } } else if (param.GetType() == typeof(System.Type)) { info = new ToolboxItemInfo("Gtk.Widget"); } else { return(null); } } break; case "System.ComponentModel.CategoryAttribute": attr.Resolve(); if (attr.ConstructorParameters.Count > 0) { object param = attr.ConstructorParameters [0]; if (param.GetType() == typeof(string)) { category = (string)param; } } break; default: continue; } } if (info == null && tdef.BaseType != null) { info = GetToolboxItemInfo(resolver, resolver.Resolve(tdef.BaseType)); } if (info != null) { info.PaletteCategory = category; } return(info); }
void AddDependencies(XmlElement elem, AssemblyResolver resolver, string filename, AssemblyDefinition asm) { string dir = Path.GetDirectoryName (filename); foreach (AssemblyNameReference aref in asm.MainModule.AssemblyReferences) { string file = null; if (resolver != null) resolver.Resolve (aref.FullName, dir); if (file != null && Application.InternalIsWidgetLibrary (resolver, file)) { XmlElement edep = elem.OwnerDocument.CreateElement ("dependency"); edep.InnerText = file; elem.AppendChild (edep); } } }
AssemblyDefinition ResolveAssembly(AssemblyNameReference aref) { return(resolver.Resolve(aref, Path.GetDirectoryName(filename))); }
ToolboxItemInfo GetToolboxItemInfo(AssemblyResolver resolver, TypeDefinition tdef) { if (tdef == null) return null; ToolboxItemInfo info = null; string category = "General"; foreach (CustomAttribute attr in tdef.CustomAttributes) { switch (attr.Constructor.DeclaringType.FullName) { case "System.ComponentModel.ToolboxItemAttribute": attr.Resolve (); if (attr.ConstructorParameters.Count > 0) { object param = attr.ConstructorParameters [0]; if (param == null) return null; else if (param.GetType () == typeof (bool)) { if ((bool) param) info = new ToolboxItemInfo ("Gtk.Widget"); else return null; } else if (param.GetType () == typeof (System.Type)) info = new ToolboxItemInfo ("Gtk.Widget"); else return null; } break; case "System.ComponentModel.CategoryAttribute": attr.Resolve (); if (attr.ConstructorParameters.Count > 0) { object param = attr.ConstructorParameters [0]; if (param.GetType () == typeof (string)) category = (string) param; } break; default: continue; } } if (info == null && tdef.BaseType != null) info = GetToolboxItemInfo (resolver, resolver.Resolve (tdef.BaseType)); if (info != null) info.PaletteCategory = category; return info; }
bool ReferenceChainContainsGtk (AssemblyResolver resolver, AssemblyNameReference aref, Hashtable visited) { if (aref.Name == "gtk-sharp") return true; else if (visited.Contains (aref.Name)) return false; visited [aref.Name] = aref; AssemblyDefinition adef = resolver.Resolve (aref); if (adef == null) return false; foreach (AssemblyNameReference child in adef.MainModule.AssemblyReferences) if (ReferenceChainContainsGtk (resolver, child, visited)) return true; return false; }
internal static bool InternalIsWidgetLibrary (AssemblyResolver resolver, string assemblyRef) { string path; if (assemblyRef.EndsWith (".dll") || assemblyRef.EndsWith (".exe")) { if (!File.Exists (assemblyRef)) return false; path = assemblyRef; } else { path = resolver.Resolve (assemblyRef, null); if (path == null) return false; } return CecilWidgetLibrary.IsWidgetLibrary (path); }
void LoadLibraries (AssemblyResolver resolver, Hashtable visited, IEnumerable libraries) { // Convert all assembly names to assembly paths before registering the libraries. // The registry and the library cache will only handle full paths. foreach (string s in libraries) { string sr = resolver.Resolve (s, null); if (sr != null) AddLibrary (resolver, visited, sr); } Registry.ReloadWidgetLibraries (); }
TypeDefinition FindTypeDefinition (Hashtable visited, AssemblyResolver resolver, string basePath, AssemblyDefinition asm, string fullName) { if (visited.Contains (asm)) return null; visited [asm] = asm; TypeDefinition cls = asm.MainModule.GetType (fullName); if (cls != null) return cls; foreach (AssemblyNameReference aref in asm.MainModule.AssemblyReferences) { AssemblyDefinition basm = resolver.Resolve (aref, basePath); if (basm != null) { cls = basm.MainModule.GetType (fullName); if (cls != null) return cls; } } return null; }