Tranga-Website/Tranga/Chapter.cs

33 lines
1.2 KiB
C#
Raw Normal View History

2023-05-18 20:06:29 +02:00
using System.Globalization;
namespace Tranga;
/// <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>
public struct Chapter
{
public string? name { get; }
public string? volumeNumber { get; }
public string? chapterNumber { get; }
public string url { get; }
public string fileName { get; }
2023-05-20 02:39:23 +02:00
public string sortNumber { get; }
public Chapter(string? name, string? volumeNumber, string? chapterNumber, string url)
{
this.name = name;
this.volumeNumber = volumeNumber;
this.chapterNumber = chapterNumber;
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:39:23 +02:00
sortNumber = decimal.Round(Convert.ToDecimal(volumeNumber) * Convert.ToDecimal(chapterNumber, nfi), 1)
.ToString(nfi);
this.fileName = $"{chapterName} - V{volumeNumber}C{chapterNumber} - {sortNumber}";
}
}