Skip to content

Commit

Permalink
名称変更とDI登録
Browse files Browse the repository at this point in the history
  • Loading branch information
aiueo-1234 committed Mar 3, 2024
1 parent 8da4ce7 commit 00ed0be
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace KoeBook.Epub.Contracts.Services;

public interface IEpubGeneration
public interface IEpubCreateService
{
ValueTask<bool> TryCreateEpubAsync(EpubDocument epubDocument, string tmpDirectory, CancellationToken ct);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using System.Text;

namespace KoeBook.Epub.Services;
public class EpubGeneration : IEpubGeneration
public class EpubCreateService : IEpubCreateService
{
public async ValueTask<bool> TryCreateEpubAsync(EpubDocument epubDocument,string tmpDirectory, CancellationToken ct)
public async ValueTask<bool> TryCreateEpubAsync(EpubDocument epubDocument, string tmpDirectory, CancellationToken ct)
{
if (!File.Exists(epubDocument.CoverFilePath))
{
Expand Down
6 changes: 4 additions & 2 deletions KoeBook.Core/Services/EpubGenerateService.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using KoeBook.Core.Contracts.Services;
using KoeBook.Core.Models;
using KoeBook.Epub;
using KoeBook.Epub.Contracts.Services;
using KoeBook.Epub.Models;

namespace KoeBook.Core.Services;

public class EpubGenerateService(ISoundGenerationService soundGenerationService, IEpubDocumentStoreService epubDocumentStoreService) : IEpubGenerateService
public class EpubGenerateService(ISoundGenerationService soundGenerationService, IEpubDocumentStoreService epubDocumentStoreService, IEpubCreateService epubCreateService) : IEpubGenerateService
{
private ISoundGenerationService _soundGenerationService = soundGenerationService;
private IEpubDocumentStoreService _documentStoreService = epubDocumentStoreService;
private IEpubCreateService _createService = epubCreateService;

public async ValueTask<string> GenerateEpubAsync(BookScripts bookScripts, string tempDirectory, CancellationToken cancellationToken)
{
Expand All @@ -22,7 +24,7 @@ public async ValueTask<string> GenerateEpubAsync(BookScripts bookScripts, string
scriptLine.Paragraph.Audio = new Audio(await _soundGenerationService.GenerateLineSoundAsync(scriptLine, bookScripts.Options, cancellationToken).ConfigureAwait(false));
}

if (await document.TryCreateEpubAsync(tempDirectory, bookScripts.BookProperties.Id.ToString(), cancellationToken).ConfigureAwait(false))
if (await _createService.TryCreateEpubAsync(document, tempDirectory, cancellationToken).ConfigureAwait(false))
{
_documentStoreService.Unregister(bookScripts.BookProperties.Id);
return Path.Combine(tempDirectory, $"{bookScripts.BookProperties.Id}.epub");
Expand Down
1 change: 1 addition & 0 deletions KoeBook/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public App()
services.AddSingleton<IScraperSelectorService, ScraperSelectorService>()
.AddSingleton<IScrapingService, ScrapingAozoraService>()
.AddSingleton<IScrapingService, ScrapingNaroService>();
services.AddSingleton<IEpubCreateService, EpubCreateService>();
// Views and ViewModels
services.AddTransient<SettingsViewModel>();
Expand Down

0 comments on commit 00ed0be

Please sign in to comment.