Skip to content

Commit f89db94

Browse files
committed
#149 - decorator on MEDI
1 parent a3191f2 commit f89db94

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

src/Infrastructure/HydraScript.Infrastructure/Dumping/DumpingLexer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using System.Diagnostics.CodeAnalysis;
22
using System.IO.Abstractions;
33
using HydraScript.Domain.FrontEnd.Lexer;
4+
using Microsoft.Extensions.DependencyInjection;
45
using Microsoft.Extensions.Options;
56

67
namespace HydraScript.Infrastructure.Dumping;
78

89
internal class DumpingLexer(
10+
[FromKeyedServices(DecoratorKey.Value)]
911
ILexer lexer,
1012
IFileSystem fileSystem,
1113
IOptions<InputFile> inputFile) : ILexer

src/Infrastructure/HydraScript.Infrastructure/Dumping/DumpingParser.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
using System.IO.Abstractions;
22
using HydraScript.Domain.FrontEnd.Parser;
3+
using Microsoft.Extensions.DependencyInjection;
34

45
namespace HydraScript.Infrastructure.Dumping;
56

6-
internal class DumpingParser(IParser parser, IFileSystem fileSystem) : IParser
7+
internal class DumpingParser(
8+
[FromKeyedServices(DecoratorKey.Value)] IParser parser,
9+
IFileSystem fileSystem) : IParser
710
{
811
public IAbstractSyntaxTree Parse(string text)
912
{

src/Infrastructure/HydraScript.Infrastructure/Dumping/DumpingVirtualMachine.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System.IO.Abstractions;
22
using HydraScript.Domain.BackEnd;
3+
using Microsoft.Extensions.DependencyInjection;
34
using Microsoft.Extensions.Options;
45

56
namespace HydraScript.Infrastructure.Dumping;
67

78
internal class DumpingVirtualMachine(
9+
[FromKeyedServices(DecoratorKey.Value)]
810
IVirtualMachine virtualMachine,
911
IFileSystem fileSystem,
1012
IOptions<InputFile> inputFile) : IVirtualMachine

src/Infrastructure/HydraScript.Infrastructure/ServiceCollectionExtensions.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ public static void AddInfrastructure(
4848

4949
if (dump)
5050
{
51-
services.Decorate<ILexer, DumpingLexer>();
52-
services.Decorate<IParser, DumpingParser>();
53-
services.Decorate<IVirtualMachine, DumpingVirtualMachine>();
51+
services.AddKeyedSingleton<ILexer, RegexLexer>(DecoratorKey.Value);
52+
services.AddSingleton<ILexer, DumpingLexer>();
53+
54+
services.AddKeyedSingleton<IParser, TopDownParser>(DecoratorKey.Value);
55+
services.AddSingleton<IParser, DumpingParser>();
56+
57+
services.AddKeyedSingleton<IVirtualMachine, VirtualMachine>(DecoratorKey.Value);
58+
services.AddSingleton<IVirtualMachine, DumpingVirtualMachine>();
5459
}
5560

5661
services.AddSingleton<Executor>();
5762
}
58-
}
63+
}

0 commit comments

Comments
 (0)