2023-05-18 20:06:29 +02:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
|
|
namespace Tranga;
|
2023-05-17 23:23:01 +02:00
|
|
|
|
|
2023-05-19 19:52:24 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Has to be Part of a publication
|
|
|
|
|
/// Includes the Chapter-Name, -VolumeNumber, -ChapterNumber, the location of the chapter on the internet and the saveName of the local file.
|
|
|
|
|
/// </summary>
|
2023-05-17 23:23:01 +02:00
|
|
|
|
public struct Chapter
|
|
|
|
|
{
|
2023-05-18 16:03:00 +02:00
|
|
|
|
public string? name { get; }
|
|
|
|
|
public string? volumeNumber { get; }
|
|
|
|
|
public string? chapterNumber { get; }
|
2023-05-18 16:21:21 +02:00
|
|
|
|
public string url { get; }
|
2023-05-18 19:51:26 +02:00
|
|
|
|
public string fileName { get; }
|
2023-05-17 23:23:01 +02:00
|
|
|
|
|
2023-05-19 19:32:47 +02:00
|
|
|
|
public Chapter(string? name, string? volumeNumber, string? chapterNumber, string url)
|
2023-05-17 23:23:01 +02:00
|
|
|
|
{
|
|
|
|
|
this.name = name;
|
|
|
|
|
this.volumeNumber = volumeNumber;
|
|
|
|
|
this.chapterNumber = chapterNumber;
|
2023-05-18 16:21:21 +02:00
|
|
|
|
this.url = url;
|
2023-05-18 20:06:29 +02:00
|
|
|
|
string chapterName = string.Concat((name ?? "").Split(Path.GetInvalidFileNameChars()));
|
2023-05-20 02:10:10 +02:00
|
|
|
|
NumberFormatInfo nfi = new NumberFormatInfo()
|
|
|
|
|
{
|
|
|
|
|
NumberDecimalSeparator = "."
|
|
|
|
|
};
|
2023-05-20 02:23:37 +02:00
|
|
|
|
decimal orderNumber = Convert.ToDecimal(volumeNumber) * Convert.ToDecimal(chapterNumber, nfi);
|
|
|
|
|
this.fileName = $"{chapterName} - V{volumeNumber}C{chapterNumber} - {decimal.Round(orderNumber, 1).ToString(nfi)}";
|
2023-05-17 23:23:01 +02:00
|
|
|
|
}
|
|
|
|
|
}
|