Skip to content

Commit 8117b2c

Browse files
committed
#165 - impl DumpingService
1 parent f523660 commit 8117b2c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1+
using System.IO.Abstractions;
2+
using Cysharp.Text;
3+
using Microsoft.Extensions.Options;
4+
15
namespace HydraScript.Infrastructure.Dumping;
26

37
public interface IDumpingService
48
{
5-
void Dump(string content, string fileExtension);
9+
void Dump(string? contents, string fileExtension);
610
}
711

8-
internal sealed class DumpingService : IDumpingService
12+
internal sealed class DumpingService(
13+
IFileSystem fileSystem,
14+
IOptions<FileInfo> fileInfo) : IDumpingService
915
{
10-
public void Dump(string content, string fileExtension)
16+
public void Dump(string? contents, string fileExtension)
1117
{
12-
throw new NotImplementedException();
18+
var fileNameWithExtension = fileInfo.Value.Name;
19+
var originalFileExtension = fileInfo.Value.Extension;
20+
var fileName = fileNameWithExtension.Replace(originalFileExtension, string.Empty);
21+
var path = Path.Combine(
22+
fileInfo.Value.DirectoryName ?? string.Empty,
23+
ZString.Concat(fileName, ".", fileExtension));
24+
fileSystem.File.WriteAllText(path, contents);
1325
}
1426
}

0 commit comments

Comments
 (0)