public void PopulateDependencies(FzServiceDirectory serviceDirectory, FzFileCache fileCache) { // For each route-builder... // 1.Find referenced sub-components // 2.Add referenced sub-components to the starting component // 3.Recurseivly for each sub-component, start again from #1 var flatFileCache = GetFlatFileCache(fileCache); var cursorLeft = Console.CursorLeft; var cursorTop = Console.CursorTop; var currentJob = 1; var totalJobs = serviceDirectory.Services.Count; _deadline = DateTime.Now.AddMinutes(2); foreach (var service in serviceDirectory.Services) { // TODO: REMOVE THIS FOR FINAL VERSION if (!service.File.FileName.Contains("PrepareForIdCards")) { continue; } Console.SetCursorPosition(cursorLeft, cursorTop); Console.WriteLine($"Working on {currentJob} of {totalJobs} ({service.Name})..."); currentJob++; FindSubComponentsOfComponent(service, flatFileCache); } }
public FzServiceDirectory GetAllServices(FzFileCache fileCache) { var serviceDirectory = new FzServiceDirectory(); PopulateRouteBuilders(serviceDirectory, fileCache.BaseDirectory); return(serviceDirectory); }
public static void FindAllComponents(FzServiceDirectory serviceDirectory, FzFileCache fileCache) { var taskList = new List <Task>(); var serviceComponentList = new List <FzServiceComponent>(); // Setup each service component foreach (var serviceComponent in serviceDirectory.Services) { var newServiceComponent = new FzServiceComponent { File = serviceComponent.File, Name = serviceComponent.Name, OutboundUrl = serviceComponent.OutboundUrl, PreviousReferencedComponent = serviceComponent.PreviousReferencedComponent, SubComponents = new List <FzServiceComponent>() }; serviceComponentList.Add(newServiceComponent); } // Find each service component as a task foreach (var serviceComponent in serviceComponentList) { taskList.Add(Task.Run(() => FindSubComponentsOfComponent(serviceComponent, fileCache))); } // Await for each service to finish foreach (var runningTask in taskList) { runningTask.GetAwaiter().GetResult(); } // Populate all finished service components back into the service directory foreach (var serviceDirectoryServiceComponent in serviceDirectory.Services) { foreach (var serviceComponent in serviceComponentList) { if (serviceDirectoryServiceComponent.Name.Equals(serviceComponent.Name)) { serviceDirectoryServiceComponent.SubComponents.AddRange(serviceComponent.SubComponents); } } } }
public FzFileCache LoadSourceFiles(string sourceJavaDirectory) { FzFileCache fileCache = LoadFileCache(); if (fileCache != null) { return(fileCache); } fileCache = new FzFileCache { BaseDirectory = new FzDirectory { Path = sourceJavaDirectory }, SourceJavaDirectory = sourceJavaDirectory }; DirectorySearch(fileCache.BaseDirectory); SaveFileCache(fileCache); return(fileCache); }
private static void FillOutSourcesOfComponents(List <FzServiceComponent> serviceComponents, FzFileCache fileCache) { foreach (var serviceComponent in serviceComponents) { foreach (var file in GetFlatFileCache(fileCache)) { // Find @Component components var componentComponentMatch = Regex.Match(file.Content, @"@Component(.*)""" + serviceComponent.Name); if (componentComponentMatch.Success) { serviceComponent.File = file; break; } // Find base class / parent components var baseClassMatch = Regex.Match(file.Content, @"class " + serviceComponent.Name); if (baseClassMatch.Success) { serviceComponent.File = file; break; } } } }
private static void FindSubComponentsOfComponent(FzServiceComponent serviceComponent, FzFileCache fileCache) { var subComponents = GetComponentsUsedInComponent(serviceComponent); FillOutSourcesOfComponents(subComponents, fileCache); serviceComponent.SubComponents.AddRange(subComponents); foreach (var subComponent in serviceComponent.SubComponents) { FindSubComponentsOfComponent(subComponent, fileCache); } }
private static List <FzFile> GetFlatFileCache(FzFileCache fileCache) => GetFlatFileCache_FillOutDirectory(fileCache.BaseDirectory);
private void SaveFileCache(FzFileCache fileCache) { var jsonText = JsonConvert.SerializeObject(fileCache); File.WriteAllText(FileCachePath, jsonText); }