private static ReferencesViewModel SelectReferenceSection(ReferencesViewModel allReferences, Location range) { ReferencesViewModel referenceSection = new ReferencesViewModel(); foreach (var reference in allReferences) { Dictionary <string, Section> sections = new Dictionary <string, Section>(); foreach (var referenceKey in reference.Value.ReferenceKeys) { foreach (var location in referenceKey.Value.Locations) { if (location.IsIn(range)) { sections.Add(referenceKey.Key, referenceKey.Value); continue; } } } if (sections.Count > 0) { var referenceCloned = (MapFileItemViewModel)reference.Value.Clone(); referenceCloned.ReferenceKeys = sections; referenceSection.AddItem(referenceCloned); } } return(referenceSection); }
public ReferencesPage() { InitializeComponent(); BindingContext = new ReferencesViewModel { navigation = Navigation }; }
public ActionResult References() { const int topReferenceCases = 4; var cases = _caseService.GetBySpecification(new CaseSpecification { Take = topReferenceCases }); ReferencesViewModel model = new ReferencesViewModel { Cases = cases }; return(View(model)); }
public AnalyseResultViewModel(LoadingErrorViewModel errorLoadingViewModel, MismatchVersionViewModel mismatchVersionViewModel, ReferencesViewModel analyseResultViewModel, AssemblyStatisticsViewModel assemblyStatisticsViewModel, CheckCommand checkCommand) { ErrorLoadingViewModel = errorLoadingViewModel; MismatchVersionViewModel = mismatchVersionViewModel; ReferencesViewModel = analyseResultViewModel; AssemblyStatisticsViewModel = assemblyStatisticsViewModel; this.checkCommand = checkCommand; CircularDependenciesCheckCommand = new Command(async() => await this.checkCommand.CircularDependenciesCheck(assemblyResult !).ConfigureAwait(false), () => assemblyResult is not null); MissingentryPointCheckCommand = new Command(async() => await this.checkCommand.EntryPointNotFoundCheck(assemblyResult !).ConfigureAwait(false), () => assemblyResult is not null); }
public async Task <ActionResult> References() { var model = new ReferencesViewModel { ReferencedLinks = await db.ReferencedLinks .Select(l => new TranslatedViewModel <ReferencedLink, ReferencedLinkTranslation> { Entity = l }) .ToListAsync(), TechnicalDocuments = await db.TechnicalDocuments.ToListAsync() }; return(View(model)); }
public ParseResult Run(MapFileItemViewModel item, IndexerContext context) { var filePath = context.MarkdownFilePath; var apis = context.ExternalApiIndex; var content = context.MarkdownContent; var links = LinkParser.Select(content); if (links == null || links.Count == 0) { return(new ParseResult(ResultLevel.Info, "No Api reference found for {0}", filePath)); } if (item.References == null) { item.References = new ReferencesViewModel(); } ReferencesViewModel references = item.References; foreach (var matchDetail in links) { var referenceId = matchDetail.Id; var apiId = matchDetail.Id; MetadataItem api; if (apis.TryGetValue(apiId, out api)) { var reference = new MapFileItemViewModel { Id = referenceId, ReferenceKeys = matchDetail.MatchedSections, Href = FileExtensions.MakeRelativePath(Path.GetDirectoryName(filePath), api.Href), MapFileType = MapFileType.Link }; // Api Index file only contains Id and Href references.AddItem(reference); } } return(new ParseResult(ResultLevel.Success)); }
private IEnumerable <string> GetReferences(IEnumerable <string> loadedReferences) { var references = loadedReferences.ToArray(); var assemblyReferences = references.Select(s => new AssemblyReference(s) { IsOptional = true, IsInstalled = true, }); var dialogDataContext = new ReferencesViewModel(assemblyReferences, ViewModel.Preferences.RecentReferences); var dlg = new ReferencesDialogWindow { Owner = this, DataContext = dialogDataContext }; var referencesUpdated = dlg.ShowDialog(); if (referencesUpdated == true) { var selectedReferences = dialogDataContext.InstalledReferences.References; references = selectedReferences.Select(reference => reference.Location).ToArray(); var recentReferences = dialogDataContext.RecentReferences.References .Distinct() .Take(50) .Select(r => r.Location); ViewModel.SetRecentReferences(recentReferences); } return(references); }
public Bookmarks() { InitializeComponent(); this.Loaded += (object sender, RoutedEventArgs e) => { if (this.DataContext is BookmarksViewModel) { BookmarksViewModel vm = (BookmarksViewModel)this.DataContext; BookmarkListViewModel view_model = new BookmarkListViewModel(vm.User, vm.WorkStatus, new DialogService(), new WindowService()); Page _mainPage = new BookmarkList(view_model); _mainPage.DataContext = view_model; _mainFrame.Navigate(_mainPage); } else if (this.DataContext is ReferencesViewModel) { ReferencesViewModel vm = (ReferencesViewModel)this.DataContext; ReferenceListViewModel view_model = new ReferenceListViewModel(vm.User, vm.WorkStatus, new DialogService(), new WindowService()); Page _mainPage = new ReferenceList(view_model); _mainPage.DataContext = view_model; _mainFrame.Navigate(_mainPage); } }; }
public ActionResult Index() { var viewModel = new ReferencesViewModel(base.BasketCount, referencesDb); return(View(viewModel)); }
public ParseResult Run(MapFileItemViewModel item, IndexerContext context) { var filePath = context.MarkdownFilePath; var content = context.MarkdownContent; var codeSnippets = CodeSnippetParser.Select(content); if (codeSnippets == null || codeSnippets.Count == 0) { return(new ParseResult(ResultLevel.Info, "No code snippet reference found for {0}", filePath)); } if (item.References == null) { item.References = new ReferencesViewModel(); } ReferencesViewModel references = item.References; var defaultReferenceFolder = Environment.CurrentDirectory; var referenceFolder = string.IsNullOrEmpty(context.ReferenceOutputFolder) ? defaultReferenceFolder : context.ReferenceOutputFolder; foreach (var codeSnippet in codeSnippets) { var referenceId = codeSnippet.Id; var codeSnippetPath = FileExtensions.GetFullPath(Path.GetDirectoryName(filePath), codeSnippet.Path); // As reference, copy file to local var targetFileName = FileExtensions.MakeRelativePath(referenceFolder, codeSnippetPath).ToValidFilePath(); // Append ref incase the file name starts with ".", which means a hidden file in Linux targetFileName = "ref" + targetFileName; var targetPath = Path.Combine(referenceFolder, targetFileName); MapFileItemViewModel reference; if (!File.Exists(codeSnippetPath)) { reference = new MapFileItemViewModel { Id = referenceId, ReferenceKeys = codeSnippet.MatchedSections, Message = string.Format("{0} does not exist.", Path.GetFullPath(codeSnippetPath)), MapFileType = MapFileType.CodeSnippet }; ParseResult.WriteToConsole(ResultLevel.Warn, reference.Message); } else { FileExtensions.CopyFile(codeSnippetPath, targetPath); reference = new MapFileItemViewModel { Id = referenceId, ReferenceKeys = codeSnippet.MatchedSections, Href = FileExtensions.MakeRelativePath(Path.GetDirectoryName(filePath), targetPath).BackSlashToForwardSlash(), Startline = codeSnippet.StartLine, Endline = codeSnippet.EndLine, MapFileType = MapFileType.CodeSnippet }; } // Api Index file only contains Id and Href references.AddItem(reference); } return(new ParseResult(ResultLevel.Success)); }
public ActionResult Index() { var model = new ReferencesViewModel(this.references); return(View(model)); }
public ParseResult Run(MapFileItemViewModel item, IndexerContext context) { var filePath = context.MarkdownFilePath; var content = context.MarkdownContent; var apis = context.ExternalApiIndex; var apiMapFileOutputFolder = context.ApiMapFileOutputFolder; var yamlHeaders = YamlHeaderParser.Select(content); if (yamlHeaders == null || yamlHeaders.Count == 0) { return(new ParseResult(ResultLevel.Info, "No valid yaml header reference found for {0}", filePath)); } if (item.References == null) { item.References = new ReferencesViewModel(); } ReferencesViewModel references = item.References; List <MarkdownSection> sections = SplitToSections(content, yamlHeaders); Dictionary <string, MarkdownSection> validMarkdownSections = new Dictionary <string, MarkdownSection>(); foreach (var markdownSection in sections) { if (!string.IsNullOrEmpty(markdownSection.Id)) { validMarkdownSections[markdownSection.Id] = markdownSection; } } foreach (var yamlHeader in yamlHeaders) { var referenceId = yamlHeader.Id; var apiId = yamlHeader.Id; MetadataItem api; if (apis.TryGetValue(apiId, out api)) { var reference = new MapFileItemViewModel { Id = referenceId, ReferenceKeys = yamlHeader.MatchedSections, Href = api.Href, }; // *DONOT* Add references to Markdown file // references.AddItem(reference); // 2. Write api reference to API's map file MarkdownSection markdownSection; if (!validMarkdownSections.TryGetValue(apiId, out markdownSection)) { continue; } var apiPath = api.Href; var apiIndexPath = context.ApiIndexFilePath; var apiYamlPath = FileExtensions.GetFullPath(Path.GetDirectoryName(apiIndexPath), apiPath); string apiMapFileName = Path.GetFileName(apiPath) + Constants.MapFileExtension; string apiFolder = Path.GetDirectoryName(apiYamlPath); // Use the same folder as api.yaml if the output folder is not set string apiMapFileFolder = (string.IsNullOrEmpty(apiMapFileOutputFolder) ? apiFolder : apiMapFileOutputFolder); string apiMapFileFullPath = FileExtensions.GetFullPath(apiMapFileFolder, apiMapFileName); // Path should be the relative path from .yml to .md var markdownFilePath = context.MarkdownFilePath; var indexFolder = Path.GetDirectoryName(context.ApiIndexFilePath); var apiYamlFilePath = FileExtensions.GetFullPath(indexFolder, api.Href); var relativePath = FileExtensions.MakeRelativePath(Path.GetDirectoryName(apiYamlFilePath), markdownFilePath).BackSlashToForwardSlash(); MapFileItemViewModel apiMapFileSection = new MapFileItemViewModel { Id = apiId, Remote = item.Remote, Href = relativePath, Startline = markdownSection.Location.StartLocation.Line + 1, Endline = markdownSection.Location.EndLocation.Line + 1, // Endline + 1 - 1, +1 for it starts from 0, -1 for it is actually the start line for next charactor, in code snippet, is always a \n References = SelectReferenceSection(references, markdownSection.Location), CustomProperties = yamlHeader.Properties, MapFileType = MapFileType.Yaml }; MapFileViewModel apiMapFile; if (File.Exists(apiMapFileFullPath)) { apiMapFile = JsonUtility.Deserialize <MapFileViewModel>(apiMapFileFullPath); } else { apiMapFile = new MapFileViewModel(); } // Current behavior: Override existing one apiMapFile[apiId] = apiMapFileSection; // Post-process item // if references'/overrides count is 0, set it to null if (apiMapFileSection.References != null && apiMapFileSection.References.Count == 0) { apiMapFileSection.References = null; } if (apiMapFileSection.CustomProperties != null && apiMapFileSection.CustomProperties.Count == 0) { apiMapFileSection.CustomProperties = null; } JsonUtility.Serialize(apiMapFileFullPath, apiMapFile); ParseResult.WriteToConsole(ResultLevel.Success, "Successfully generated {0}.", apiMapFileFullPath); } } // Select references to the indices where DefinedLine is between startline and endline return(new ParseResult(ResultLevel.Success)); }