// check if given assembly belongs to pyrevit public static bool IsPyRevitAssembly(Assembly assm) { try { var clone = new PyRevitClone(Path.GetDirectoryName(assm.Location)); return(true); } catch { return(false); } }
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { try { // only respond if the request is coming from a pyRevit assembly if (args.RequestingAssembly != null && PyRevitClone.IsPyRevitAssembly(args.RequestingAssembly)) { // this handler is called only when the runtime tries to bind to the assembly and fails // retrieve the name and dll name of the missing assembly string missingAssm = args.Name; if (args.Name.IndexOf(",") > -1) { missingAssm = args.Name.Substring(0, args.Name.IndexOf(",")); } string missingAssmDllName = missingAssm + ".dll"; // assuming this assembly has been shipped with this module, build the path and test of it exists // in current assembly directory var fullAssmDllPath = Path.Combine(Path.GetDirectoryName(typeof(PyRevit).Assembly.Location), missingAssmDllName); // load it if it exists if (File.Exists(fullAssmDllPath)) { // load the assembly from the specified path. var foundAssm = Assembly.LoadFrom(fullAssmDllPath); // return the loaded assembly. return(foundAssm); } } } catch { // just ignore if any exceptions occured due to null references and extracting assembly names // if exceptions is balooned up, the refrencing assemnly will have issues } return(null); }
public static PyRevitEngine GetEngineFromManifest(RevitAddonManifest manifest, PyRevitClone clone) { foreach (var engine in clone.GetEngines()) { if (manifest.Assembly.Contains(engine.Path)) { return(engine); } } return(null); }
// get list of builtin extensions // @handled @logs public static List <PyRevitExtension> GetExtensions(string clonePath) { VerifyCloneValidity(clonePath); return(PyRevitExtension.FindExtensions(PyRevitClone.GetExtensionsPath(clonePath))); }
public void SetClone(PyRevitClone clone) { _clone = clone; }