コード例 #1
0
 // 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);
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: PyRevitEngine.cs プロジェクト: Jamesbdsas/DynamoDS
 public static PyRevitEngine GetEngineFromManifest(RevitAddonManifest manifest, PyRevitClone clone)
 {
     foreach (var engine in clone.GetEngines())
     {
         if (manifest.Assembly.Contains(engine.Path))
         {
             return(engine);
         }
     }
     return(null);
 }
コード例 #4
0
 // get list of builtin extensions
 // @handled @logs
 public static List <PyRevitExtension> GetExtensions(string clonePath)
 {
     VerifyCloneValidity(clonePath);
     return(PyRevitExtension.FindExtensions(PyRevitClone.GetExtensionsPath(clonePath)));
 }
コード例 #5
0
 public void SetClone(PyRevitClone clone)
 {
     _clone = clone;
 }