private void TryAdd(IApplicationCollection applications, string filePath) { if (File.Exists(filePath)) { FileVersionInfo version = FileVersionInfo.GetVersionInfo(filePath); IApplicationBuilder builder = applications.Add( String.Format("Visual Studio {0}", VersionFormatter.Format(version)), new Version(version.FileMajorPart, version.FileMinorPart, version.FileBuildPart), filePath, null, null, false, IconExtractor.Get(filePath), Key.None, true ); AddAdministratorCommand(builder, filePath); AddExperimentalCommand(builder, filePath); } }
public void Add(IApplicationCollection applications) { foreach (var(name, filePath, version) in Enumerate()) { IApplicationBuilder builder = applications.Add( String.Format( "{0} {1}", name, VersionFormatter.Format(version) ), version, filePath, null, null, false, IconExtractor.Get(filePath), Key.None, true ); VsVersionLoader.AddAdministratorCommand(builder, filePath); VsVersionLoader.AddExperimentalCommand(builder, filePath); } }
public void Add(IApplicationCollection applications) { List <(string suffix, IFile file)> files = new List <(string suffix, IFile file)>(); foreach (var search in EnumerateProgramFolders()) { IDirectory directory = search .directory .FindDirectories(TextSearch.CreateMatched("Microsoft VS Code")) .FirstOrDefault(); if (directory == null) { continue; } IFile file = directory .WithFileEnumerator() .FirstOrDefault(f => f.Name == "Code" && f.Extension == "exe"); if (file == null) { continue; } files.Add((search.suffix, file)); } if (files.Count == 0) { return; } foreach (var search in files) { string filePath = search.file.WithAbsolutePath().AbsolutePath; FileVersionInfo version = FileVersionInfo.GetVersionInfo(filePath); IApplicationBuilder builder = applications.Add( String.Format( "VS Code{0} {1}", files.Count == 1 ? String.Empty : " " + search.suffix, VersionFormatter.Format(version) ), new Version(version.FileMajorPart, version.FileMinorPart), filePath, null, "{DirectoryPath}", false, IconExtractor.Get(filePath), Key.None, true ); builder.AddCommand( "Run as Administrator", filePath, null, null, true, Key.A ); } }