public RootDirectoryViewModel(ViewModelBase root, FromSoftwareFile fromSoftwareFile) : base(root, null, true) { FromSoftwareFile = fromSoftwareFile; CanBeEdited = false; ImagePath = ImageHelper.BuildImageSourceFromDatabase(fromSoftwareFile.GameName); }
public async Task CheckGame2FilesAndDirCountTest() { var game2 = new FromSoftwareFile(_rootDirectory, "*.sl2", "Game2", true, string.Empty); var actualCount = await GetTree(game2); Assert.That(7, Is.EqualTo(actualCount)); }
public FileViewModel(ViewModelBase root, FromSoftwareFile fromSoftwareFile, ITreeViewItemViewModel parent) : base(root, parent, fromSoftwareFile.IsDirectory) { FromSoftwareFile = fromSoftwareFile; CanBeEdited = true; _backupFileName = fromSoftwareFile.FileName; FileName = fromSoftwareFile.FileName; }
private static async Task <int> GetTree(FromSoftwareFile fromSoftwareFile) { int childrenCount = 0; var children = await FileRepository.LoadChildrenAsync(fromSoftwareFile); foreach (var child in children) { childrenCount++; int subChildrenCount = await GetTree(child); childrenCount += subChildrenCount; } return(childrenCount); }
public static async Task <List <FromSoftwareFile> > LoadChildrenAsync(FromSoftwareFile fromSoftwareFile) { if (!fromSoftwareFile.IsDirectory) { return(Empty); } var filePath = Path.Combine(fromSoftwareFile.Path, fromSoftwareFile.FileName); return(await Task.Run(() => { return FromSoftwareFileSearch.GetGameFiles(fromSoftwareFile.RootDirectory, filePath, fromSoftwareFile.FileSearchPattern) .Union(FromSoftwareFileSearch.GetSubDirectories(fromSoftwareFile.RootDirectory, filePath)) .Select(childrenFile => new FromSoftwareFile(fromSoftwareFile.RootDirectory, fromSoftwareFile.FileSearchPattern, Path.GetFileName(childrenFile), Directory.Exists(childrenFile), filePath)) .ToList(); })); }