示例#1
0
文件: Package.cs 项目: whztt07/Dynamo
        private void LoadAssembliesIntoDynamo(DynamoLoader loader, ILogger logger, LibraryServices libraryServices)
        {
            var assemblies = LoadAssembliesInBinDirectory(logger);

            // filter the assemblies
            var zeroTouchAssemblies = new List <Assembly>();
            var nodeModelAssemblies = new List <Assembly>();

            foreach (var assem in assemblies)
            {
                if (loader.ContainsNodeModelSubType(assem))
                {
                    nodeModelAssemblies.Add(assem);
                }
                else
                {
                    zeroTouchAssemblies.Add(assem);
                }
            }

            // load the zero touch assemblies
            foreach (var zeroTouchAssem in zeroTouchAssemblies)
            {
                libraryServices.ImportLibrary(zeroTouchAssem.Location, logger);
            }

            // load the node model assemblies
            foreach (var nodeModelAssem in nodeModelAssemblies)
            {
                var nodes = loader.LoadNodesFromAssembly(nodeModelAssem);
                nodes.ForEach(x => LoadedTypes.Add(x));
            }
        }
示例#2
0
        private void LoadAssembliesIntoDynamo(DynamoLoader loader, LibraryServices libraryServices, string context)
        {
            var assemblies = LoadAssembliesInBinDirectory();

            // filter the assemblies
            var zeroTouchAssemblies = new List <Assembly>();
            var nodeModelAssemblies = new List <Assembly>();

            // categorize the assemblies to load, skipping the ones that are not identified as node libraries
            foreach (var assem in assemblies.Where(x => x.IsNodeLibrary).Select(x => x.Assembly))
            {
                if (loader.ContainsNodeModelSubType(assem))
                {
                    nodeModelAssemblies.Add(assem);
                }
                else
                {
                    zeroTouchAssemblies.Add(assem);
                }
            }

            // load the zero touch assemblies
            foreach (var zeroTouchAssem in zeroTouchAssemblies)
            {
                libraryServices.ImportLibrary(zeroTouchAssem.Location);
            }

            // load the node model assemblies
            var nodes = nodeModelAssemblies.SelectMany(
                assem =>
            {
                var assemblyNodes = new List <TypeLoadData>();
                loader.LoadNodesFromAssembly(assem, context, assemblyNodes, new List <TypeLoadData>());
                return(assemblyNodes);
            });

            foreach (var node in nodes)
            {
                LoadedTypes.Add(node.Type);
            }
        }