/// <summary> /// /// </summary> /// <param name="iMemberInfoHandler"></param> /// <param name="iBeforeEnqueueMemberInfo"></param> /// <param name="iTaskException"></param> public static void Register(Func <MemberInformation, bool> iMemberInfoHandler, Func <MemberInformation, bool> iBeforeEnqueueMemberInfo = null, EventHandler <UnobservedTaskExceptionEventArgs> iTaskException = null) { LibraryInformation.Initialize(); ThreadLocalInformation.Initialize(); if (_loopRecord.zzIsNotNull()) { _loopRecord.Stop(); //TODO: Wait. } if (iMemberInfoHandler.zzIsNull()) { throw new ArgumentNullException(nameof(iMemberInfoHandler), "iMemberInfoHandler.zzIsNull()"); } ThreadLocalMemberObserver.MemberInfoHandler = iMemberInfoHandler; if (iBeforeEnqueueMemberInfo.zzIsNotNull()) { ThreadLocalMemberObserver.BeforeEnqueueMemberInfo = iBeforeEnqueueMemberInfo; } TaskScheduler.UnobservedTaskException += (iTaskException.zzIsNull() ? ThreadLocalMemberObserver.UnobservedTaskException : iTaskException); _loopRecord = LoopObserver.SpinUntilInBackground(memberInfoHandler, TaskCreationOptions.LongRunning); //TODO: Test self. }
private async Task <LibraryInformation> GetLibraryInformation() { using (StringAsTempFile file = new StringAsTempFile(GetResource($"{PATH}.BaseProcessor.js"), CancellationToken.None)) { string result = await NodeServices.InvokeAsync <string>(file.FileName, GetLibrary()); LibraryInformation libraryInformation = JsonConvert.DeserializeObject <LibraryInformation>(result); return(libraryInformation); } }
protected List <KeyValuePair <string, string> > GetMetaDataShared() { LibraryInformation libraryInformation = GetLibraryInformation().Result; List <KeyValuePair <string, string> > metaData = new List <KeyValuePair <string, string> >(); metaData.Add(new KeyValuePair <string, string>("Library Name", libraryInformation.Name)); metaData.Add(new KeyValuePair <string, string>("Library Version", libraryInformation.Version)); metaData.Add(new KeyValuePair <string, string>("Library Runtime", libraryInformation.Runtime)); return(metaData); }
private static LibraryInformation FilterByVersionAndArchitecture(params LibraryInformation[] libraries) { LibraryArchitecture targetArchictecture = Environment.Is64BitProcess ? LibraryArchitecture.amd64 : LibraryArchitecture.i386; LibraryInformation result = libraries[0]; foreach (LibraryInformation library in libraries) { if (IsNewer(result.Version, library.Version) && library.Architecture == targetArchictecture) { result = library; } } return(result); }
private void btnStart_Click(object sender, EventArgs e) { if (SharepointClient == null) { Utilities.Utilities.ShowErrorMessage("Not logged in", "You are not connected to a Sharepoint site\r\nPlease log in from the menu and try again"); return; } tbOutput.AppendText("Running...\r\n"); var listName = tbSpLibrary.Text; var destinationFolder = tbTargetFolder.Text; bw.WorkerReportsProgress = true; bw.DoWork += doWork; var libraryInfo = new LibraryInformation(listName, destinationFolder, SharepointClient); bw.RunWorkerAsync(libraryInfo); bw.RunWorkerCompleted += bwCompleted; }
public static string Resolve(string name, LibrarySearchOptions searchOptions = LibrarySearchOptions.Default, string customRoot = "") { SearchOption directorySearchOption = (searchOptions & LibrarySearchOptions.IncludeSubDirectories) != 0 ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; #region Custom root directory if ((searchOptions & LibrarySearchOptions.IncludeCustomRootDirectory) != 0) { string[] paths = Directory.GetFiles(customRoot, "*" + name + "*", directorySearchOption); LibraryInformation[] libraries = FilterPaths(name, paths); if (libraries.Length > 0) { foreach (LibraryInformation library in libraries) { Debug.Log("Found '" + Path.GetFileName(library.Path) + "'"); } LibraryInformation newest = FilterByVersionAndArchitecture(libraries); return(newest.Path); } } #endregion #region Working directory if ((searchOptions & LibrarySearchOptions.IncludeTopDirectory) != 0) { string[] paths = Directory.GetFiles(Directory.GetCurrentDirectory(), "*" + name + "*", directorySearchOption); LibraryInformation[] libraries = FilterPaths(name, paths); if (libraries.Length > 0) { foreach (LibraryInformation library in libraries) { Debug.Log("Found '" + Path.GetFileName(library.Path) + "'"); } LibraryInformation newest = FilterByVersionAndArchitecture(libraries); return(newest.Path); } } #endregion #region OS specific string[][] staggeredPaths = _osSpecificResolver.Resolve(name, searchOptions); foreach (string[] paths in staggeredPaths) { LibraryInformation[] libraries = FilterPaths(name, paths); if (libraries.Length > 0) { foreach (LibraryInformation library in libraries) { Debug.Log("Found '" + Path.GetFileName(library.Path) + "'"); } LibraryInformation newest = FilterByVersionAndArchitecture(libraries); return(newest.Path); } } #endregion // If all else fails return(name); }
public static string Locate(string name, LibrarySearchOptions searchOptions = LibrarySearchOptions.Default, string customRoot = "") { SearchOption directorySearchOption = (searchOptions & LibrarySearchOptions.IncludeSubDirectories) != 0 ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; #region Working directory if ((searchOptions & LibrarySearchOptions.IncludeTopDirectory) != 0) { string[] paths = Directory.GetFiles(Directory.GetCurrentDirectory(), "*" + name + "*", directorySearchOption); LibraryInformation[] libraries = FilterPaths(name, paths); foreach (LibraryInformation library in libraries) { Debug.Log("Found '" + Path.GetFileName(library.Path) + "'"); } if (libraries.Length > 0) { LibraryInformation newest = FilterByVersionAndArchitecture(libraries); return(newest.Path); } } #endregion #region System directory if ((searchOptions & LibrarySearchOptions.IncludeSystemDirectory) != 0) { string[] paths = Directory.GetFiles(Directory.GetCurrentDirectory(), "*" + name + "*", SearchOption.TopDirectoryOnly); LibraryInformation[] libraries = FilterPaths(name, paths); foreach (LibraryInformation library in libraries) { Debug.Log("Found '" + Path.GetFileName(library.Path) + "'"); } if (libraries.Length > 0) { LibraryInformation newest = FilterByVersionAndArchitecture(libraries); return(newest.Path); } } #endregion #region PATH directories if ((searchOptions & LibrarySearchOptions.IncludePathDirectories) != 0) { char pathDelimiter = ';'; if (PlatformInformation.Platform == OSPlatform.Linux || PlatformInformation.Platform == OSPlatform.OSX) { pathDelimiter = ':'; } string[] pathPaths = Environment.GetEnvironmentVariable("PATH").Split(pathDelimiter); foreach (string pathPath in pathPaths) { try { if (!Directory.Exists(pathPath)) { continue; } string[] paths = Directory.GetFiles(pathPath, "*" + name + "*", SearchOption.TopDirectoryOnly); LibraryInformation[] libraries = FilterPaths(name, paths); foreach (LibraryInformation library in libraries) { Debug.Log("Found '" + Path.GetFileName(library.Path) + "'"); } if (libraries.Length > 0) { LibraryInformation newest = FilterByVersionAndArchitecture(libraries); return(newest.Path); } } catch (UnauthorizedAccessException) { } } } #endregion #region Custom root directory if ((searchOptions & LibrarySearchOptions.IncludeCustomRootDirectory) != 0) { string[] paths = Directory.GetFiles(customRoot, "*" + name + "*", directorySearchOption); LibraryInformation[] libraries = FilterPaths(name, paths); foreach (LibraryInformation library in libraries) { Debug.Log("Found '" + Path.GetFileName(library.Path) + "'"); } if (libraries.Length > 0) { LibraryInformation newest = FilterByVersionAndArchitecture(libraries); return(newest.Path); } } #endregion // If all else fails return(string.Empty); }