EnumerateAssembliesInBinDirectory() private method

Enumerates all assemblies in the package
private EnumerateAssembliesInBinDirectory ( ) : IEnumerable
return IEnumerable
Beispiel #1
0
        /// <summary>
        ///     Load the package into Dynamo (including all node libraries and custom nodes)
        ///     and add to LocalPackages
        /// </summary>
        public void Load(Package package)
        {
            this.Add(package);

            // Prevent duplicate loads
            if (package.Loaded)
            {
                return;
            }

            try
            {
                // load node libraries
                foreach (var assem in package.EnumerateAssembliesInBinDirectory())
                {
                    if (assem.IsNodeLibrary)
                    {
                        OnRequestLoadNodeLibrary(assem.Assembly);
                    }
                }

                // load custom nodes
                var customNodes = OnRequestLoadCustomNodeDirectory(package.CustomNodeDirectory);
                package.LoadedCustomNodes.AddRange(customNodes);

                package.EnumerateAdditionalFiles();
                package.Loaded = true;
            }
            catch (Exception e)
            {
                Log("Exception when attempting to load package " + package.Name + " from " + package.RootDirectory);
                Log(e.GetType() + ": " + e.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Try loading package into Library (including all node libraries and custom nodes)
        /// and add to LocalPackages.
        /// </summary>
        /// <param name="package"></param>
        internal void TryLoadPackageIntoLibrary(Package package)
        {
            this.Add(package);

            // Prevent duplicate loads
            if (package.Loaded)
            {
                return;
            }

            try
            {
                // load node libraries
                foreach (var assem in package.EnumerateAssembliesInBinDirectory())
                {
                    if (assem.IsNodeLibrary)
                    {
                        try
                        {
                            OnRequestLoadNodeLibrary(assem.Assembly);
                        }
                        catch (LibraryLoadFailedException ex)
                        {
                            Log(ex.GetType() + ": " + ex.Message);
                        }
                    }
                }

                // load custom nodes
                var customNodes = OnRequestLoadCustomNodeDirectory(package.CustomNodeDirectory);
                package.LoadedCustomNodes.AddRange(customNodes);

                package.EnumerateAdditionalFiles();
                // If the additional files contained an extension manifest, then request it be loaded.
                var extensionManifests = package.AdditionalFiles.Where(
                    file => file.Model.Name.Contains("ExtensionDefinition.xml") && !(file.Model.Name.Contains("ViewExtensionDefinition.xml"))).ToList();
                foreach (var extPath in extensionManifests)
                {
                    var extension = RequestLoadExtension?.Invoke(extPath.Model.FullName);
                    if (extension != null)
                    {
                        RequestAddExtension?.Invoke(extension);
                    }
                    this.requestedExtensions.Add(extension);
                }

                package.Loaded = true;
                this.PackgeLoaded?.Invoke(package);
            }
            catch (Exception e)
            {
                Log("Exception when attempting to load package " + package.Name + " from " + package.RootDirectory);
                Log(e.GetType() + ": " + e.Message);
            }
        }
Beispiel #3
0
        /// <summary>
        ///     Load the package into Dynamo (including all node libraries and custom nodes)
        ///     and add to LocalPackages
        /// </summary>
        public void Load(Package package)
        {
            this.Add(package);

            // Prevent duplicate loads
            if (package.Loaded) return;

            try
            {
                // load node libraries
                foreach (var assem in package.EnumerateAssembliesInBinDirectory())
                {
                    if (assem.IsNodeLibrary)
                    {
                        OnRequestLoadNodeLibrary(assem.Assembly);
                    }
                }

                // load custom nodes
                var customNodes = OnRequestLoadCustomNodeDirectory(package.CustomNodeDirectory);
                package.LoadedCustomNodes.AddRange(customNodes);

                package.EnumerateAdditionalFiles();
                package.Loaded = true;
            }
            catch (Exception e)
            {
                Log("Exception when attempting to load package " + package.Name + " from " + package.RootDirectory);
                Log(e.GetType() + ": " + e.Message);
            }
        }