public static List <BeatmapDataModel> ToDataModelList(this IEnumerable <IMapIdentifiable> identifiable, bool distinctByVersion = false) { List <BeatmapDataModel> ret; switch (identifiable) { case ObservableCollection <Beatmap> beatmaps1: ret = beatmaps1.InnerToDataModelList(); break; case List <Beatmap> beatmaps: ret = beatmaps.InnerToDataModelList(); break; case ObservableCollection <BeatmapDataModel> dataModels1: ret = dataModels1.ToList(); break; case List <BeatmapDataModel> dataModels: ret = dataModels; break; case List <BeatmapSettings> infos: ret = _beatmapDbOperator.GetBeatmapsByIdentifiable(infos).InnerToDataModelList(); break; default: throw new ArgumentOutOfRangeException(nameof(identifiable), identifiable?.GetType(), "Not support source type."); } return(ret.Distinct(new DataModelComparer(distinctByVersion)).ToList()); }
public List <Beatmap> GetBeatmapsByIdentifiable(IEnumerable <IMapIdentifiable> mapIdentities) { try { return(_dbOperator.GetBeatmapsByIdentifiable(mapIdentities)); } catch (Exception ex) { Notification.Push($"Error while getting beatmaps by IMapIdentifiable from database: {ex.Message}"); return(new List <Beatmap>()); } }