private void AddCurrentSongToList()
        {
            var songInfo = this.SongInfo.Value;
            var info     = new ZanmaiSongInfo
            {
                Title      = songInfo.Title,
                Artists    = songInfo.Artists.Split(','),
                Genre      = songInfo.Genre,
                Series     = songInfo.Series,
                SongType   = songInfo.SongType,
                Additional = songInfo.Additional,
            };

            if (songInfo.IsSpecialItem)
            {
                info.SpecialHeader   = songInfo.SpecialHeader;
                info.SpecialItemName = songInfo.SpecialItemName;
                info.Number          = 0;
            }
            else
            {
                info.Number = this.SongNumber.Value;
            }

            this.SongsSubject.OnNext(info);
        }
        public ZanmaiSongInfoViewModel(ZanmaiSongInfo zanmaiSongInfo)
        {
            if (zanmaiSongInfo == null)
            {
                throw new ArgumentNullException(nameof(zanmaiSongInfo));
            }

            this.Number           = zanmaiSongInfo.Number;
            this.Title            = zanmaiSongInfo.Title;
            this.Artists          = string.Join(",", zanmaiSongInfo.Artists);
            this.Genre            = zanmaiSongInfo.Genre;
            this.Series           = zanmaiSongInfo.Series;
            this.SongType         = zanmaiSongInfo.SongType;
            this.IsSpecialItem    = zanmaiSongInfo.IsSpecialItem;
            this.SpecialHeader    = zanmaiSongInfo.SpecialHeader;
            this.SpecialItemName  = zanmaiSongInfo.SpecialItemName;
            this.Additional       = zanmaiSongInfo.Additional;
            this.ShortDescription = zanmaiSongInfo.ShortDescription;
        }
        public string SerializeFull(ZanmaiSongInfo info)
        {
            var sb = new StringBuilder();

            var body      = this.Serialize(info, false);
            var isSpecial = !string.IsNullOrWhiteSpace(info.SpecialHeader);

            if (isSpecial)
            {
                sb.Append(info.SpecialHeader);
                sb.Append(info.SpecialItemName);
                body = body.Substring(1);
            }
            else
            {
                sb.AppendFormat("{0:0000}", info.Number);
            }

            sb.Append(body);
            return(sb.ToString());
        }
Esempio n. 4
0
        public override async Task <ZanmaiSongInfo> ConvertToZanmaiSongInfoAsync(
            ISongSearchResult songSearchResult,
            CancellationToken cancellationToken = default)
        {
            if (songSearchResult is AnisonDbNameSongSearchResult result)
            {
                var info = new ZanmaiSongInfo
                {
                    Title    = result.Title,
                    Series   = result.Series,
                    Genre    = result.Genre,
                    Artists  = result.Artists,
                    SongType = this.CheckSeries ? await this.FindActualSongTypeAsync(result, cancellationToken).ConfigureAwait(false) : result.SongType
                };

                return(this.SongInfoConverter.Convert(info));
            }
            else
            {
                throw new ArgumentException("unsupported result type.", nameof(songSearchResult));
            }
        }
        private string Serialize(ZanmaiSongInfo info, bool appendAll)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            // フォーマット構築
            StringBuilder sb = new StringBuilder();

            sb.Append(".「{0}」");

            var hasArtist = info.Artists?.Any() == true;

            if (appendAll || hasArtist)
            {
                sb.Append("/{1}");
            }

            var hasSeries   = !string.IsNullOrWhiteSpace(info.Series);
            var hasGenre    = !string.IsNullOrWhiteSpace(info.Genre);
            var hasSongType = !string.IsNullOrWhiteSpace(info.SongType);

            if (appendAll || hasSeries || hasSongType)
            {
                sb.Append("(");
            }

            // 使用作品名追加
            if (hasSeries)
            {
                // ジャンル追加
                if (hasGenre)
                {
                    sb.Append("[{2}]");
                }

                sb.Append("{3}");
            }

            // 曲種追加
            if (hasSongType)
            {
                sb.Append(" {4}");
            }

            if (appendAll || hasSeries || hasSongType)
            {
                sb.Append(")");
            }

            // 補足追加
            if (!string.IsNullOrWhiteSpace(info.Additional))
            {
                sb.Append("※{5}");
            }

            var result = string.Format(
                sb.ToString(),
                info.Title,
                string.Join(",", info.Artists),
                info.Genre,
                info.Series,
                info.SongType,
                info.Additional);

            for (int i = 0; i < replaceList.Length - 1; i++)
            {
                result = Regex.Replace(result, replaceList[i], replaceList[i + 1]);
            }
            return(result);
        }
 public string Serialize(ZanmaiSongInfo info)
 {
     return(this.Serialize(info, true));
 }