internal BotBitsClient(ISchedulerHandle handle) { this._packageLoader = new PackageLoader(this); this.Extensions = new List<Type>(); DefaultExtension.LoadInto(this, handle); }
public void GetOwnerPackageReturnsPackageForValidFunctionDefinition() { var loader = new PackageLoader(PackagesDirectory); loader.RequestLoadCustomNodeDirectory += (dir) => this.CurrentDynamoModel.CustomNodeManager.AddUninitializedCustomNodesInPath(dir, true); loader.LoadAll(new LoadPackageParams { Preferences = this.CurrentDynamoModel.PreferenceSettings }); var pkg = loader.LocalPackages.FirstOrDefault(x => x.Name == "Custom Rounding"); Assert.AreEqual(3, pkg.LoadedCustomNodes.Count); foreach (var nodeInfo in pkg.LoadedCustomNodes) { CustomNodeDefinition funcDef; Assert.IsTrue(this.CurrentDynamoModel.CustomNodeManager.TryGetFunctionDefinition(nodeInfo.FunctionId, true, out funcDef)); Assert.IsNotNull(funcDef); var foundPkg = loader.GetOwnerPackage(nodeInfo); Assert.IsNotNull(foundPkg); Assert.AreEqual(pkg.Name, foundPkg.Name); Assert.IsTrue(pkg.Name == foundPkg.Name); } }
public void PackageLoadTest() { using (var loader = new PackageLoader(null)) { loader.AddPackages(new AssemblyCatalog(Assembly.GetExecutingAssembly()), null); Assert.IsNull(loader.Get<TestPackage>().BotBits); } }
/// <summary>Constructor.</summary> /// <param name="initMethod">The entry point method to invoke upon load completion.</param> /// <param name="scriptUrl">The URL to the JavaScript file to load.</param> private PackageInfo(string initMethod, string scriptUrl) { // Setup initial conditions. if (string.IsNullOrEmpty(scriptUrl)) throw new Exception("A URL to the test-package script must be specified."); if (string.IsNullOrEmpty(initMethod)) throw new Exception("An entry point method must be specified."); // Store values. name = GetName(scriptUrl); loader = new PackageLoader(this, initMethod, scriptUrl); }
public void DisposeTest() { TestPackage package; using (var loader = new PackageLoader(null)) { loader.AddPackages(new AssemblyCatalog(Assembly.GetExecutingAssembly()), null); package = loader.Get<TestPackage>(); } Assert.IsTrue(package.IsDisposed); }
public void LoadPackagesReturnsAllValidPackagesInValidDirectory() { var loader = new PackageLoader(PackagesDirectory); loader.LoadAll(new LoadPackageParams { Preferences = this.CurrentDynamoModel.PreferenceSettings }); // There are four packages in "GitHub\Dynamo\test\pkgs" Assert.AreEqual(4, loader.LocalPackages.Count()); }
public void LoadPackagesReturnsNoPackagesForInvalidDirectory() { var pkgDir = Path.Combine(PackagesDirectory, "No directory"); var loader = new PackageLoader(pkgDir); loader.LoadAll(new LoadPackageParams { Preferences = this.CurrentDynamoModel.PreferenceSettings }); Assert.AreEqual(0, loader.LocalPackages.Count()); }
public void LocalizedPackageLocalizedCorrectly() { var esculture = CultureInfo.CreateSpecificCulture("es-ES"); // Save current culture - usually "en-US" var currentCulture = Thread.CurrentThread.CurrentCulture; var currentUICulture = Thread.CurrentThread.CurrentUICulture; // Set "es-ES" Thread.CurrentThread.CurrentCulture = esculture; Thread.CurrentThread.CurrentUICulture = esculture; var loader = new PackageLoader(new[] { PackagesDirectory }, new[] { string.Empty }); var libraryLoader = new ExtensionLibraryLoader(CurrentDynamoModel); loader.PackagesLoaded += libraryLoader.LoadPackages; loader.RequestLoadNodeLibrary += libraryLoader.LoadNodeLibrary; var pkgDir = Path.Combine(PackagesDirectory, "Dynamo Samples"); var pkg = loader.ScanPackageDirectory(pkgDir, false); // Assert that ScanPackageDirectory returns a package Assert.IsNotNull(pkg); loader.LoadPackages(new List <Package> { pkg }); // Verify that the package are imported successfully var entries = CurrentDynamoModel.SearchModel.SearchEntries.ToList(); var nse = entries.Where(x => x.FullName == "SampleLibraryUI.Examples.LocalizedNode").FirstOrDefault(); Assert.IsNotNull(nse); //verify that the node has the correctly localized description Assert.AreEqual("Un nodo de interfaz de usuario de muestra que muestra una interfaz de usuario personalizada." , nse.Description); var node = nse.CreateNode(); Assert.AreEqual("Un nodo de interfaz de usuario de muestra que muestra una interfaz de usuario personalizada." , nse.Description); // Restore "en-US" Thread.CurrentThread.CurrentCulture = currentCulture; Thread.CurrentThread.CurrentUICulture = currentUICulture; }
private PackagePathViewModel CreatePackagePathViewModel(PreferenceSettings settings) { var pathManager = new PathManager(new PathManagerParams { }) { Preferences = settings }; PackageLoader loader = new PackageLoader(pathManager); LoadPackageParams loadParams = new LoadPackageParams { Preferences = settings, }; CustomNodeManager customNodeManager = Model.CustomNodeManager; return(new PackagePathViewModel(loader, loadParams, customNodeManager)); }
public void GetOwnerPackageReturnsNullForInvalidFunction() { var loader = new PackageLoader(PackagesDirectory); CustomNodeInfo info; Assert.IsTrue( this.CurrentDynamoModel.CustomNodeManager.AddUninitializedCustomNode( Path.Combine(new string[] { TestDirectory, "core", "combine", "combine2.dyf" }), true, out info)); CustomNodeDefinition funcDef; Assert.IsTrue(this.CurrentDynamoModel.CustomNodeManager.TryGetFunctionDefinition(info.FunctionId, true, out funcDef)); var foundPkg = loader.GetOwnerPackage(info); Assert.IsNull(foundPkg); }
public void NewPackageVersionUpload_DoesNotThrowExceptionWhenDLLIsLoadedSeveralTimes() { string packagesDirectory = Path.Combine(TestDirectory, "pkgs"); var loader = new PackageLoader(packagesDirectory); loader.LoadAll(new LoadPackageParams { Preferences = ViewModel.Model.PreferenceSettings }); PublishPackageViewModel vm = null; Assert.DoesNotThrow(() => { vm = PublishPackageViewModel.FromLocalPackage(ViewModel, loader.LocalPackages.First()); }); Assert.AreEqual(PackageUploadHandle.State.Error, vm.UploadState); }
public static void Main(string[] args) { projectPath = (args.Length == 0) ? "./" : args[0]; if (Directory.GetFiles(projectPath, "*.csproj").Length == 0) { Console.WriteLine(args.Length == 0 ? "Project not found in current directory" : "Project not found in the directory specified"); return; } DateTime startTime = DateTime.UtcNow; CommandLineUtils.PrintInfoMessage("Plugin is running... "); string projectName = new DirectoryInfo(projectPath).Name; RetrieveNugetProperties(string.Format(nugetPropsFile, projectPath, projectName)); CommandLineUtils.PrintInfoMessage($"Project Name: {projectName}"); string projectFilePath = Path.Combine(projectPath, string.Format(projectFile, projectName)); if (TryGetPolicy(out ProjectPolicy policy)) { if (File.Exists(projectFilePath)) { CommandLineUtils.PrintInfoMessage("Finding project dependencies... "); List <NuGetPackage> packagesFound = PackageLoader.LoadPackages(projectFilePath, projectAssetsPath) .Distinct() .ToList(); CommandLineUtils.PrintSuccessMessage("Finding project dependencies DONE"); CommandLineUtils.PrintInfoMessage("Searching for dependencies licenses and vulnerabilities... "); List <Dependency> dependenciesEvaluated = ValidateProjectDependencies(packagesFound, policy).Result; CommandLineUtils.PrintSuccessMessage("Searching for dependencies licenses and vulnerabilities DONE"); string report = GenerateReport(dependenciesEvaluated, policy); CommandLineUtils.PrintSuccessMessage("Produced report locally."); StoreReport(report); double seconds = (DateTime.UtcNow - startTime).TotalSeconds; CommandLineUtils.PrintInfoMessage("Plugin execution time: " + seconds); } else { CommandLineUtils.PrintErrorMessage($"Packages.config file not found in project {projectName}"); } } }
private static void ExtractPkg(FileInfo file, bool appendFolderName = false, string defaultProjectName = "") { Console.WriteLine(Resources.ExtractingPackage, file.FullName); // Load package var loader = new PackageLoader(true); var package = loader.Load(file); // Get output directory string outputDirectory; var preview = string.Empty; if (appendFolderName) { GetProjectFolderNameAndPreviewImage(file, defaultProjectName, out outputDirectory, out preview); } else { outputDirectory = _options.OutputDirectory; } // Extract package entries var entries = FilterEntries(package.Entries); foreach (var entry in entries) { ExtractEntry(entry, ref outputDirectory); } // Copy project files project.json/preview image if (!_options.CopyProject || _options.SingleDir || file.Directory == null) { return; } var files = file.Directory.GetFiles().Where(x => x.Name.Equals(preview, StringComparison.OrdinalIgnoreCase) || ProjectFiles.Contains(x.Name, StringComparer.OrdinalIgnoreCase)); CopyFiles(files, outputDirectory); }
public void PackageInStandardLibLocationIsLoaded() { //setup clean loader var loader = new PackageLoader(new string[0], StandardLibraryTestDirectory); var settings = new PreferenceSettings(); settings.DisableStandardLibrary = false; var loaderParams = new LoadPackageParams() { PathManager = CurrentDynamoModel.PathManager, Preferences = settings }; //invoke the load loader.LoadAll(loaderParams); //assert the package in std lib was loaded. Assert.IsTrue(loader.LocalPackages.Any(x => x.BinaryDirectory.Contains("SignedPackage2"))); Assert.AreEqual(1, loader.LocalPackages.Count()); }
public void GetOwnerPackageReturnsPackageForValidFunctionDefinition() { var loader = new PackageLoader(PackagesDirectory); loader.LoadPackages(); var pkg = loader.LocalPackages.FirstOrDefault(x => x.Name == "Custom Rounding"); Assert.AreEqual(3, pkg.LoadedCustomNodes.Count); foreach (var nodeInfo in pkg.LoadedCustomNodes) { var funcDef = dynSettings.CustomNodeManager.GetFunctionDefinition(nodeInfo.Guid); Assert.IsNotNull(funcDef); var foundPkg = loader.GetOwnerPackage(funcDef); Assert.IsNotNull(foundPkg); Assert.AreEqual(pkg.Name, foundPkg.Name); Assert.IsTrue(pkg.Name == foundPkg.Name); } }
public void DisablingStandardLibraryCorrectlyDisablesLoading() { //setup clean loader var loader = new PackageLoader(new string[0], StandardLibraryTestDirectory); var settings = new PreferenceSettings(); settings.DisableStandardLibrary = true; var loaderParams = new LoadPackageParams() { PathManager = CurrentDynamoModel.PathManager, Preferences = settings }; //then invoke load loader.LoadAll(loaderParams); //assert the package in std lib was not loaded. Assert.IsFalse(loader.LocalPackages.Any(x => x.Name.Contains("SignedPackage2"))); Assert.AreEqual(0, loader.LocalPackages.Count()); }
public void FilterSupported(bool isBackwards) { // Arrange var item1 = _fixture.Create <NuGetReference>() with { Version = "1.0.0" }; var item2 = item1 with { Version = "2.0.0" }; var metadata1 = MockSearchMetadata(item1, TargetFrameworkMoniker.NetStandard20); var metadata2 = MockSearchMetadata(item2, TargetFrameworkMoniker.Net50); var list = isBackwards ? new[] { metadata2, metadata1 } : new[] { metadata1, metadata2 }; // Act var result = PackageLoader.FilterSearchResults(item1.Name, list, new[] { TargetFrameworkMoniker.Net50 }); // Assert Assert.Collection(result, r => Assert.Equal(r, item1), r => Assert.Equal(r, item2)); }
static void RunOptions(Options options) { Console.WriteLine(String.Format("Execution starting on {0} , database {1}, with username {2} and password {3}" , options.Server, options.Databasename, options.Username, options.Password)); Console.WriteLine(String.Format("SSIS package path {0}", options.SSISPath)); Console.WriteLine(String.Format("Dacpac path {0}", options.DacpacPath)); Console.WriteLine(options.ToString()); ConnectionStringBuilder builder = new ConnectionStringBuilder(); builder.setServer(options.Server) .setDatabase(options.Databasename) .setUserName(options.Username) .setPassword(options.Password); //Create the database from ssdt project PackageLoader pacLoader = new PackageLoader(); SSDTExecutor exec = new SSDTExecutor(builder.build()); exec.OnStatusUpdate(progressupdate); pacLoader.loadDacPac(options.DacpacPath); exec.publish(pacLoader, options.Databasename); //migrate AE encrypted data pacLoader.loadSSISPackage(options.SSISPath); var ssisrunner = new SSISExecutor(pacLoader); ssisrunner.SetServer(options.Server); ssisrunner.SetUser(options.Username); ssisrunner.SetPassword(options.Password); ssisrunner.SetDatabase(options.Databasename); string result = ssisrunner.execute(); Console.WriteLine(result); Console.ReadLine(); }
public void GetOwnerPackageReturnsPackageForValidFunctionDefinition() { //Assert.Inconclusive("Porting : Formula"); var loader = new PackageLoader(ViewModel.Model.Loader, ViewModel.Model.Logger, PackagesDirectory); loader.LoadPackagesIntoDynamo(ViewModel.Model.PreferenceSettings, ViewModel.Model.EngineController.LibraryServices); var pkg = loader.LocalPackages.FirstOrDefault(x => x.Name == "Custom Rounding"); Assert.AreEqual(3, pkg.LoadedCustomNodes.Count); foreach (var nodeInfo in pkg.LoadedCustomNodes) { var funcDef = ViewModel.Model.CustomNodeManager.GetFunctionDefinition(nodeInfo.Guid); Assert.IsNotNull(funcDef); var foundPkg = loader.GetOwnerPackage(funcDef); Assert.IsNotNull(foundPkg); Assert.AreEqual(pkg.Name, foundPkg.Name); Assert.IsTrue(pkg.Name == foundPkg.Name); } }
public DynamoLoader(DynamoModel model) { this.dynamoModel = model; this.PackageLoader = new PackageLoader(this, dynamoModel.Logger); }
public PackageManagerCommands(PackageLoader loader, DynamoModel model) : base(loader, model) { }
public PackageManagerCommands(PackageLoader loader, DynamoModel model) { this.Loader = loader; this.Model = model; }
private static void InfoPKG(FileInfo file, string name) { var projectInfo = GetProjectInfo(file); if (!MatchesFilter(projectInfo)) { return; } Console.WriteLine(Resources.InfoAboutPackage, name); if (projectInfo != null && _projectInfoToPrint != null && _projectInfoToPrint.Length > 0) { IEnumerable <string> projectInfoEnumerator; if (_projectInfoToPrint.Length == 1 && _projectInfoToPrint[0] == "*") { projectInfoEnumerator = Helper.GetPropertyKeysForDynamic(projectInfo); } else { projectInfoEnumerator = Helper.GetPropertyKeysForDynamic(projectInfo); projectInfoEnumerator = projectInfoEnumerator.Where(x => _projectInfoToPrint.Contains(x, StringComparer.OrdinalIgnoreCase)); } foreach (var key in projectInfoEnumerator) { if (projectInfo[key] == null) { Console.WriteLine(key + @": null"); } else { Console.WriteLine(key + @": " + projectInfo[key].ToString()); } } } if (_options.PrintEntries) { Console.WriteLine(Resources.PackageEntries); var loader = new PackageLoader(false); var package = loader.Load(file); var entries = package.Entries; if (_options.Sort) { if (_options.SortBy == "extension") { entries.Sort((a, b) => String.Compare(a.EntryPath, b.EntryPath, StringComparison.OrdinalIgnoreCase)); } else if (_options.SortBy == "size") { entries.Sort((a, b) => a.Length.CompareTo(b.Length)); } else { entries.Sort((a, b) => String.Compare(a.EntryPath, b.EntryPath, StringComparison.OrdinalIgnoreCase)); } } foreach (var entry in entries) { Console.WriteLine(@"* " + entry.FullName + $@" - {entry.Length} bytes"); } } }
public void Process() { // Retrieve operation value from options. string operationValue = this.options.Operation; // Inform the user of the requested operation if applicable. Log.Verbose($"Using operation: {operationValue}"); // Resolve operation value. OperationType operation = Operation.Resolve(operationValue); // Ensure operation type is not unknown. if (operation == OperationType.Unknown) { Log.Error($"Unknown operation: '{operationValue}'."); } // Inform the user that the requested operation is valid, if applicable. Log.Verbose("Requested operation is valid."); // Set the operation for future use. this.operation = operation; // Set the root directory. string root = Directory.GetCurrentDirectory(); // Use specified root directory. if (!String.IsNullOrEmpty(this.options.Root)) { // Ensure provided root directory exists. if (!Directory.Exists(options.Root)) { Log.Error("The specified root directory path does not exist."); } // Use provided root directory path. root = Path.GetFullPath(this.options.Root); } // Inform the user of the final root directory. Log.Verbose($"Using root directory: {root}"); // Ensure root directory exists. if (!Directory.Exists(root)) { Log.Error("Root directory does not exist."); } // TODO: Should never modify options' root path. // Apply root directory to options. this.options.Root = root; // Inform the user that the root directory is valid. Log.Verbose("Root directory is valid."); // If operation is to initialize, simply initialize and finish. if (this.operation == OperationType.Init) { // Invoke the initialization operation handler. this.HandleInitOperation(); // Terminate this function. return; } // Create a new package loader instance. PackageLoader packageLoader = new PackageLoader(root); // Ensure package manifest exists. if (!packageLoader.DoesManifestExist) { Log.Error("Package manifest file does not exist."); } // Inform the user that the package manifest exists. Log.Verbose("Package manifest file exists."); // Load the package manifest. Package package = packageLoader.ReadPackage(); // Inform the user that the package manifest was loaded. Log.Verbose("Package manifest file loaded."); // Process package options if applicable. if (package.Options != null) { // Use package's root path option if applicable. if (package.Options.SourceRoot != null) { // Create the source directory path. string sourcePath = Path.GetFullPath(package.Options.SourceRoot); // Inform the user of the source directory path. Log.Verbose($"Using source directory: {sourcePath}"); // Ensure directory path exists. if (!Directory.Exists(sourcePath)) { Log.Error("Provided source root directory path in package manifest does not exist."); } // Inform the user that the source directory exists. Log.Verbose("Source directory is valid."); // Override root path. root = Path.GetFullPath(package.Options.SourceRoot); // Inform the user of the action taken. Log.Verbose($"Using source root directory from package manifest: {root}"); } } // Process scanner. Project project = this.ProcessScanner(root); // Summon the corresponding engine. this.SummonEngine(this.operation, package, project); }
public DynamoLoader(DynamoModel model) { this.dynamoModel = model; this.PackageLoader = new PackageLoader(dynamoModel); }
public PackageManagerCefHelper(DynamoViewModel dynamoViewModel, PackageLoader model, PackageManagerViewModel pkgManagerViewModel) : base(dynamoViewModel, model, pkgManagerViewModel) { }
public void ScanPackageDirectoryReturnsNullForInvalidDirectory() { var pkgDir = ""; var loader = new PackageLoader(); var pkg = loader.ScanPackageDirectory(pkgDir); }
public CefHelper(DynamoViewModel dynamoViewModel, PackageLoader model, PackageManagerViewModel packageMgrViewModel) { this.dynamoViewModel = dynamoViewModel; this.Model = model; this.PackageMgrViewMdodel = packageMgrViewModel; }