public FavoritePath(string name, string path, FavoritePathType type, string iconPath = null) { Name = name; Path = path; Type = type; IconPath = iconPath; }
public FavoritePaths GetFavorites(FavoritePathType type) { switch (type) { case FavoritePathType.Folders: return(FavoriteFolders); case FavoritePathType.Icons: return(FavoriteIcons); default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
public static bool IsFile(this FavoritePathType type) { switch (type) { case FavoritePathType.Folders: return(false); case FavoritePathType.Icons: return(true); default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
public static string GetNameFromPath(string path, FavoritePathType type) { switch (type) { case FavoritePathType.Folders: return(Paths.GetFileName(path)); case FavoritePathType.Icons: return(Paths.GetFileNameWithoutExtension(path)); default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
public static string GetNameFromPath(this FavoritePathType type, string path) => type.IsFile() ? Paths.GetFileNameWithoutExtension(path) : Paths.GetFileName(path);
public FavoritePath(string path, FavoritePathType type, string iconPath = null) : this(type.GetNameFromPath(path), path, type, iconPath) { }