/// <summary> /// This method is called when custom nodes and packages need to be reloaded if there are new package paths. /// </summary> /// <param name="loadPackageParams"></param> /// <param name="customNodeManager"></param> public void LoadCustomNodesAndPackages(LoadPackageParams loadPackageParams, CustomNodeManager customNodeManager) { foreach (var path in loadPackageParams.Preferences.CustomPackageFolders) { customNodeManager.AddUninitializedCustomNodesInPath(path, false, false); } LoadAll(loadPackageParams); }
private void LoadCustomNodesIntoDynamo(LoadPackageParams loadPackageParams) { var loader = loadPackageParams.CustomNodeManager; var isTestMode = loadPackageParams.IsTestMode; foreach (var info in loader.AddUninitializedCustomNodesInPath(CustomNodeDirectory, isTestMode)) { LoadedCustomNodes.Add(info); } }
public void LoadCustomNodesAndPackages(LoadPackageParams loadPackageParams, CustomNodeManager customNodeManager) { foreach (var path in loadPackageParams.Preferences.CustomPackageFolders) { customNodeManager.AddUninitializedCustomNodesInPath(path, false); if (!this.packagesDirectories.Contains(path)) { this.packagesDirectories.Add(path); } } }
public PackagePathViewModel(PackageLoader loader, LoadPackageParams loadParams, CustomNodeManager customNodeManager) { this.packageLoader = loader; this.loadPackageParams = loadParams; this.customNodeManager = customNodeManager; RootLocations = new ObservableCollection<string>(setting.CustomPackageFolders); AddPathCommand = new DelegateCommand(p => InsertPath()); DeletePathCommand = new DelegateCommand(p => RemovePathAt((int) p), CanDelete); MovePathUpCommand = new DelegateCommand(p => SwapPath((int) p, ((int) p) - 1), CanMoveUp); MovePathDownCommand = new DelegateCommand(p => SwapPath((int) p, ((int) p) + 1), CanMoveDown); UpdatePathCommand = new DelegateCommand(p => UpdatePathAt((int) p)); SaveSettingCommand = new DelegateCommand(CommitChanges); SelectedIndex = 0; }
private void LoadAssembliesIntoDynamo(LoadPackageParams loadPackageParams) { var loader = loadPackageParams.Loader; 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 var libraryServices = loadPackageParams.LibraryServices; foreach (var zeroTouchAssem in zeroTouchAssemblies) { libraryServices.ImportLibrary(zeroTouchAssem.Location); } // load the node model assemblies var context = loadPackageParams.Context; 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); } }
/// <summary> /// Scan the PackagesDirectory for packages and attempt to load all of them. Beware! Fails silently for duplicates. /// </summary> public void LoadAll(LoadPackageParams loadPackageParams) { ScanAllPackageDirectories(loadPackageParams.Preferences); var pathManager = loadPackageParams.PathManager; if (pathManager != null) { foreach (var pkg in LocalPackages) { pathManager.AddResolutionPath(pkg.BinaryDirectory); } } foreach (var pkg in LocalPackages) { Load(pkg); } }
/// <summary> /// Scan the PackagesDirectory for packages and attempt to load all of them. Beware! Fails silently for duplicates. /// </summary> public void LoadPackagesIntoDynamo(LoadPackageParams loadPackageParams) { ScanAllPackageDirectories(loadPackageParams.Preferences); var pathManager = loadPackageParams.PathManager; if (pathManager != null) { foreach (var pkg in LocalPackages) { pathManager.AddResolutionPath(pkg.BinaryDirectory); } } foreach (var pkg in LocalPackages) { pkg.LoadIntoDynamo(loadPackageParams, AsLogger()); } }
/// <summary> /// Scan the PackagesDirectory for packages and attempt to load all of them. Beware! Fails silently for duplicates. /// </summary> public void LoadAll(LoadPackageParams loadPackageParams) { ScanAllPackageDirectories(loadPackageParams.Preferences); if (pathManager != null) { foreach (var pkg in LocalPackages) { if (Directory.Exists(pkg.BinaryDirectory)) { pathManager.AddResolutionPath(pkg.BinaryDirectory); } } } if (LocalPackages.Any()) { LoadPackages(LocalPackages); } }
/// <summary> /// Load the Package into Dynamo. /// </summary> /// <param name="loadPackageParams"></param> /// <param name="logger"></param> public void LoadIntoDynamo(LoadPackageParams loadPackageParams, ILogger logger) { // Prevent duplicate loads if (Loaded) { return; } try { LoadAssembliesIntoDynamo(loadPackageParams); LoadCustomNodesIntoDynamo(loadPackageParams); EnumerateAdditionalFiles(); Loaded = true; } catch (Exception e) { Log("Exception when attempting to load package " + Name + " from " + RootDirectory); Log(e.GetType() + ": " + e.Message); } }
/// <summary> /// LoadCustomNodesAndPackages can be used to load custom nodes and packages /// from temporary paths that do not need to be added to preference settings. /// To load from temporary custom paths, initialize a local PreferenceSettings object /// and add the paths to its CustomPackageFolders property, then initialize a new /// LoadPackageParams with this preferences object and use as input to this method. /// To load from custom paths that need to be persisted to the preferences, /// initialize a LoadPackageParams from an existing preferences object. /// </summary> /// <param name="loadPackageParams">LoadPackageParams initialized with local PreferenceSettings object containing custom package path.</param> /// <param name="customNodeManager"></param> public void LoadCustomNodesAndPackages(LoadPackageParams loadPackageParams, CustomNodeManager customNodeManager) { var preferences = loadPackageParams.Preferences; LoadCustomNodesAndPackagesHelper(preferences.CustomPackageFolders, preferences, customNodeManager); }
private void DynamoViewModelRequestPackagePaths(object sender, EventArgs e) { var loadPackagesParams = new LoadPackageParams { Preferences = dynamoViewModel.PreferenceSettings, PathManager = dynamoViewModel.Model.PathManager, }; var customNodeManager = dynamoViewModel.Model.CustomNodeManager; var packageLoader = dynamoViewModel.Model.GetPackageManagerExtension().PackageLoader; var viewModel = new PackagePathViewModel(packageLoader,loadPackagesParams,customNodeManager); var view = new PackagePathView(viewModel) { Owner = this }; view.ShowDialog(); }
public void LoadCustomNodesAndPackages(LoadPackageParams loadPackageParams, CustomNodeManager customNodeManager) { foreach(var path in loadPackageParams.Preferences.CustomPackageFolders){ customNodeManager.AddUninitializedCustomNodesInPath(path, false, false); if (!this.packagesDirectories.Contains(path)) { this.packagesDirectories.Add(path); } } LoadAll(loadPackageParams); }
private PackagePathViewModel CreatePackagePathViewModel(PreferenceSettings setting) { PackageLoader loader = new PackageLoader(setting.CustomPackageFolders); LoadPackageParams loadParams = new LoadPackageParams { Preferences = setting, PathManager = Model.PathManager }; CustomNodeManager customNodeManager = Model.CustomNodeManager; return new PackagePathViewModel(loader, loadParams, customNodeManager); }