IEnumerable <IconGenerationPath> GetRelativePaths(DirectoryInfo current, DirectoryInfo rootDirectory, int priority) { //var debug = IsDebug(current); var generationRoot = new IconGenerationRoot(priority, rootDirectory); //TODO: xRemove ToArray() var roots = GetRootPaths(current, generationRoot) .Distinct() .ToArray() ; RelativePath relative = null; foreach (var root in roots) { if (!Roots.IsActionRoot(current)) { var actionRoot = Roots.GetActionRoot(current); relative = current.ParseRelativePath(actionRoot, root.Directory); yield return(new IconGenerationPath(root, 1, relative)); } if (Roots.Action != null) { relative = current.ParseRelativePath(Roots.Action, root.Directory); yield return(new IconGenerationPath(root, 2, relative)); } } if (relative == null) { yield break; } var label = relative.SubPath; var newLabels = Roots.GetAlternateRootLabels(label); //.ToArray() foreach (var newLabel in newLabels) { foreach (var root in roots) { relative = root.Directory.CreateRelativePath(newLabel); yield return(new IconGenerationPath(root, 3, relative)); } } }
private static IconGenerationResult GetIconGenerationResultFromReference(IconReference icon, double priority = 100, DirectoryInfo directory = null, bool checkIconExists = false) { if (!icon.Validate(checkIconExists)) { return(null); } //var debug = string.IsNullOrWhiteSpace(icon.BaseDirectory); var baseDirectory = string.IsNullOrWhiteSpace(icon.BaseDirectory) ? directory : DirectoriesIO.GetInfo(icon.BaseDirectory); if (directory == null) { directory = baseDirectory; } var root = new IconGenerationRoot(priority, baseDirectory); var source = new IconGenerationSource(root, root.Priority, baseDirectory); var relative = directory.ParseRelativePath(root.Directory); var path = new IconGenerationPath(source, root.Priority, relative); var folder = new IconGenerationFolder(path, root.Priority, relative.Directory); return(new IconGenerationResult(folder, root.Priority, icon)); }
IEnumerable <IconGenerationSource> GetRootPaths(DirectoryInfo current, IconGenerationRoot root) => GetRootPathsGenerator(current, root).Where(x => x.Directory != null).Distinct();
/* * bool GetCurrentIconFromIni(DirectoryInfo current, IconReference currentIcon, IconReference parentIcon, FolderIconInfo iconInfo, out IconReference finalIcon) * { * if (currentIcon.Resource != parentIcon.Resource && !currentIcon.IsEmpty) * { * finalIcon = currentIcon; * return true; * } * //TODO: Evaluate use of FolderIconInfo.Main vs FolderIconInfo.Icon/GetIconResource() * if (!string.IsNullOrEmpty(iconInfo.Main)) * { * finalIcon = currentIcon; * return false; * } * finalIcon = GetCurrentIconFromDirectory(current, iconInfo, parentIcon); * if (finalIcon.IsEmpty) * { * finalIcon = currentIcon; * return false; * } * return true; * } */ IEnumerable <IconGenerationSource> GetRootPathsGenerator(DirectoryInfo current, IconGenerationRoot root) { yield return(new IconGenerationSource(root, 5, Roots.Icons)); yield return(new IconGenerationSource(root, 2, Roots.Content)); yield return(new IconGenerationSource(root, 4, Roots.GetActionRoot(current))); yield return(new IconGenerationSource(root, 3, Roots.Action)); yield return(new IconGenerationSource(root, 1, current.GetExistingPath())); }