/// <summary> /// If the provided song exists in history, change the flag to the one provided. Returns true if the song was found. /// </summary> /// <param name="song"></param> /// <param name="flag"></param> /// <returns></returns> public bool TryUpdateFlag(PlaylistSong song, HistoryFlag flag) { if (song == null) { return(false); } return(TryUpdateFlag(song.Hash, flag)); }
/// <summary> /// If the provided song hash exists in history, change the flag to the one provided. Returns true if the song was found. /// </summary> /// <param name="songHash"></param> /// <param name="flag"></param> /// <returns></returns> public bool TryUpdateFlag(string songHash, HistoryFlag flag) { songHash = songHash.ToUpper(); if (!SongHistory.ContainsKey(songHash)) { return(false); } SongHistory[songHash].Flag = flag; SongHistory[songHash].Date = DateTime.Now; return(true); }
/// <summary> /// Tries to add the provided PlaylistSong to the SongHistory. Returns false if the PlaylistSong is null, or its hash is null/empty. /// </summary> /// <param name="song"></param> /// <returns></returns> /// <exception cref="InvalidOperationException">Thrown when trying to access data before Initialize is called on HistoryManager.</exception> public bool TryAdd(PlaylistSong song, HistoryFlag flag) { if (!IsInitialized) { throw new InvalidOperationException("HistoryManager is not initialized."); } if (song == null) { return(false); } return(TryAdd(song.Hash, song.ToString(), flag)); }
/// <summary> /// Tries to add the provided songHash and songInfo to the history. Returns false if the hash is null/empty. /// </summary> /// <param name="songHash"></param> /// <param name="songInfo"></param> /// <returns></returns> /// <exception cref="InvalidOperationException">Thrown when trying to access data before Initialize is called on HistoryManager.</exception> public bool TryAdd(string songHash, string songInfo, HistoryFlag flag) { if (!IsInitialized) { throw new InvalidOperationException("HistoryManager is not initialized."); } if (string.IsNullOrEmpty(songHash)) { return(false); } return(SongHistory.TryAdd(songHash.ToUpper(), new HistoryEntry(songInfo, flag))); }
/// <summary> /// Tries to add the provided PlaylistSong to the SongHistory. Returns false if the PlaylistSong is null, or its hash is null/empty. /// </summary> /// <param name="song"></param> /// <returns></returns> /// <exception cref="InvalidOperationException">Thrown when trying to access data before Initialize is called on HistoryManager.</exception> public bool TryAdd(ISong song, HistoryFlag flag) { if (!IsInitialized) { throw new InvalidOperationException("HistoryManager is not initialized."); } if (song == null || song.Hash == null || song.Hash.Length == 0) { return(false); } return(SongHistory.TryAdd(song.Hash.ToUpper(), new HistoryEntry(song, flag))); }
/// <summary> /// If the provided song hash exists in history, change the flag to the one provided. Returns true if the song was found. /// </summary> /// <param name="songHash"></param> /// <param name="flag"></param> /// <returns></returns> public bool TryUpdateFlag(string songHash, HistoryFlag flag) { songHash = songHash.ToUpper(); if (SongHistory.TryGetValue(songHash, out var entry)) { entry.Flag = flag; entry.Date = DateTime.Now; return(true); } else { return(false); } }
public HistoryEntry(ISong song, HistoryFlag flag = 0) { //Hash = song.Hash; //SongName = song.Name; //Mapper = song.LevelAuthorName; if (!string.IsNullOrEmpty(song.Key)) { SongInfo = $"({song.Key}) {song.Name} by {song.LevelAuthorName}"; } else { SongInfo = $"{song.Name} by {song.LevelAuthorName}"; } Flag = flag; Date = DateTime.Now; }
public HistoryEntry(string?songName, string?mapper, HistoryFlag flag = 0) { if (songName != null && songName.Length > 0) { if (mapper != null && mapper.Length > 0) { SongInfo = $"{songName} by {mapper}"; } else { SongInfo = $"{songName}"; } } Date = DateTime.Now; Flag = flag; }
public HistoryEntry(string?songInfo, HistoryFlag flag = 0) { SongInfo = songInfo; Date = DateTime.Now; Flag = flag; }
public HistoryEntry(PlaylistSong song, HistoryFlag flag = 0) { SongInfo = song.ToString(); Flag = flag; Date = DateTime.Now; }
public bool TryAdd(string songHash, string songName, string mapper, HistoryFlag flag) { return(TryAdd(songHash, $"{songName} by {mapper}", flag)); }