public void FindShortestPath(string filePath, string startWord, string endWord, string resultFilePath) { _logger.Info("Loading file..."); IEnumerable <string> words = _fileLoader.LoadFile(filePath); _logger.Info("File loaded"); _logger.Info("Building graph..."); ConcurrentDictionary <string, List <string> > graph = _graphFactory.BuildGraph(words); _logger.Info("Graph built"); int numberOfMatching = graph.Count(c => c.Value.Any()); _logger.Info($"system has found {numberOfMatching} dead end nodes of {graph.Count()}"); _logger.Info("Trying to calculate critical path..."); List <string> criticalPath; if (_shortestPathAlgorithm.TryFindShortestPath(graph, startWord, endWord, out criticalPath)) { _logger.Info("Critical path found"); _logger.Info($"Critical path is: {string.Join(" -> ", criticalPath)}"); _logger.Info("Saving file..."); _fileLoader.SaveFile(criticalPath, resultFilePath); _logger.Info("Save complete"); } else { _logger.Error($"Failed to find a path between {startWord} and {endWord}"); } }
// POST public async Task <Attendee> IdentifyProfile(IEnumerable <Attendee> people, AudioFile file, bool shortAudio = false) { // Request parameters try { string profileIds = ""; foreach (Attendee a in people) { profileIds += "," + a.ProfileID; } var url = string.Format(IndentifyProfileURL, profileIds, shortAudio); HttpResponseMessage response; // Request body IFileLoader loader = DependencyService.Get <IFileLoader>(); Stream byteData = loader.LoadFile(file.FileName); using (var content = new StreamContent(byteData)) { content.Headers.ContentType = octetMedia; response = await client.PostAsync(url, content); } var body = await response.Content.ReadAsStringAsync(); Debug.WriteLine(body); // Need get } catch (Exception e) { Debug.WriteLine(e); } return(null); }
// POST public async Task <bool> EnrolProfile(Attendee person, AudioFile file, bool shortAudio = false) { Debug.WriteLine("Enrol a Profile"); try { var url = string.Format(EnrollProfileURL, person.ProfileID, shortAudio); HttpResponseMessage response; // Request body IFileLoader loader = DependencyService.Get <IFileLoader>(); Stream byteData = loader.LoadFile(file.FileName); using (var content = new StreamContent(byteData)) { content.Headers.ContentType = octetMedia; response = await client.PostAsync(url, content); } if (!response.IsSuccessStatusCode) { var body = await response.Content.ReadAsStringAsync(); Debug.WriteLine(body); } return(response.IsSuccessStatusCode); } catch (Exception e) { Debug.WriteLine(e); } return(false); }
private IObservable <IBitmap> LoadBitmap(TdApi.File file) { if (file != null) { return(_fileLoader.LoadFile(file, LoadPriority.Max) .FirstAsync(f => f.Local != null && f.Local.IsDownloadingCompleted) .Select(f => GetBitmap(f.Local.Path))); } return(Observable.Return <Bitmap>(null)); }
private IObservable <bool> Download( DocumentMessageModel model) { var file = model.Document.Document_; return(_fileLoader.LoadFile(file, LoadPriority.Mid) .FirstAsync(f => f.Local != null && f.Local.IsDownloadingCompleted) .SubscribeOn(RxApp.TaskpoolScheduler) .ObserveOn(RxApp.MainThreadScheduler) .Select(f => f.Local.IsDownloadingCompleted)); }
private static IEnumerable <Animation> LoadAnimationFile(string animationFile, IKeyValueCollection decodeKey, IFileLoader fileLoader) { var animResource = fileLoader.LoadFile(animationFile + "_c"); if (animResource == null) { return(Enumerable.Empty <Animation>()); } // Build animation classes return(Animation.FromResource(animResource, decodeKey)); }
public Mesh LoadMesh(string path) { var mesh = new Mesh(); IEnumerable <string> lines = _fileLoader.LoadFile(path); foreach (string line in lines) { _parsingService.ProcessLine(line, mesh); } return(mesh); }
public Mesh LoadMesh(string path, FileType fileType) { string fileName = Path.GetFileName(path); var mesh = new Mesh(fileName); IEnumerable <string> lines = _fileLoader.LoadFile(path); IParsingService parsingService = _services[fileType]; foreach (string line in lines) { parsingService.ProcessLine(line, mesh); } return(mesh); }
public void CanReturnEmptyMeshWhenFileIsEmpty() { IFileLoader loader = Substitute.For <IFileLoader>(); loader.LoadFile(Arg.Any <string>()).Returns(new string[0]); IParsingService service = Substitute.For <IParsingService>(); service.ProcessLine(Arg.Any <string>(), Arg.Any <Mesh>()); Parser parser = new Parser(loader, service); Mesh mesh = parser.LoadMesh(_fixture.Create <string>()); Assert.That(mesh.Filename, Is.Null); Assert.That(mesh.SubMeshes, Is.Empty); Assert.That(mesh.Name, Is.Null); }
public static List <Animation> GetAllAnimations(Model model, IFileLoader fileLoader) { var animGroupPaths = model.GetReferencedAnimationGroupNames(); var animations = model.GetEmbeddedAnimations().ToList(); // Load animations from referenced animation groups foreach (var animGroupPath in animGroupPaths) { var animGroup = fileLoader.LoadFile(animGroupPath + "_c"); if (animGroup != default) { animations.AddRange(LoadAnimationGroup(animGroup, fileLoader)); } } return(animations.ToList()); }
private IObservable <IBitmap> LoadBitmap(TdApi.File file, long id, AvatarSize size) { var filename = GetFilename(file, id, size); if (file != null) { return(_fileLoader.LoadFile(file, LoadPriority.Max) .FirstAsync(f => f.Local != null && f.Local.IsDownloadingCompleted) .SelectMany(f => PrepareAvatar(f.Local.Path, (int)size, filename).ToObservable()) .SelectMany(path => CreateBitmap(path).ToObservable()) .Do(bitmap => { _cache.Set(filename, bitmap, new MemoryCacheEntryOptions { Size = 1 }); })); } return(Observable.Return <Bitmap>(null)); }
public IObservable <IBitmap> LoadFile(TdApi.File file, LoadPriority priority) { return(_fileLoader.LoadFile(file, priority) .FirstAsync(f => f.Local != null && f.Local.IsDownloadingCompleted) .Select(f => new Bitmap(f.Local.Path))); }
public ReverseLookup(IFileLoader fileLoader, IGeoJsonParser geoJsonParser) { _fileLoader = fileLoader; _geoJsonParser = geoJsonParser; this.Regions = ParseInput(_fileLoader.LoadFile()).ToArray(); }