-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/OnlyFart/Elib2Ebook/issues/123
- Loading branch information
OnlyFart
committed
Oct 19, 2024
1 parent
a5daacb
commit 2a96f80
Showing
6 changed files
with
72 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Collections.Generic; | ||
using Core.Extensions; | ||
using Core.Types.Book; | ||
|
||
namespace Core.Logic; | ||
|
||
public class BookNameBuilder { | ||
public const string TITLE_PATTERN = "title"; | ||
|
||
public const string AUTHOR_PATTERN = "author"; | ||
|
||
public const string SERIA_PATTERN = "seria"; | ||
|
||
public const string SERIA_NUMBER_PATTERN = "seria_number"; | ||
|
||
public static string Build(string pattern, Book book) { | ||
var map = new Dictionary<string, string> { | ||
{ TITLE_PATTERN, book.Title }, | ||
{ AUTHOR_PATTERN, book.Author.Name }, | ||
{ SERIA_PATTERN, book.Seria?.Name }, | ||
{ SERIA_NUMBER_PATTERN, book.Seria?.Number }, | ||
}; | ||
|
||
foreach (var (key, value) in map) { | ||
pattern = pattern.Replace("{" + key + "}", value.RemoveInvalidChars()); | ||
} | ||
|
||
return pattern.RemoveInvalidChars().Crop(100); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters