Esempio n. 1
0
        public static List <WebArtworkDetailed> FanartArtworkReader(SQLiteDataReader reader, int index, object param)
        {
            ArtworkReaderParameters args = (ArtworkReaderParameters)param;
            var list = ((IEnumerable <string>)DataReaders.ReadPipeList(reader, index)).Select(x =>
            {
                string[] parts = x.Split('?'); // ? is used as separator between filename and rating
                string path    = Path.Combine(args.DirectoryName, parts[0].Replace('/', '\\'));
                return(new WebArtworkDetailed()
                {
                    Type = args.FileType,
                    Path = path,
                    Offset = 0,
                    Filetype = Path.GetExtension(path).Substring(1),
                    Rating = String.IsNullOrEmpty(parts[1]) ? 1 :
                             (int)Math.Round(Single.Parse(parts[1].Replace(',', '.'), System.Globalization.CultureInfo.InvariantCulture) * 10),
                    Id = parts[2]
                });
            }).ToList();

            list.Sort(AnonymousComparer.FromLambda <WebArtworkDetailed>((x, y) => y.Rating - x.Rating));
            for (int i = 0; i < list.Count; i++)
            {
                list[i].Offset = i;
            }
            return(list);
        }