Skip to content

Commit b99703f

Browse files
authored
#149 - удаление Scrutor (#159)
* #149 - remove Scrutor package * #149 - DI key * #149 - decorator on MEDI
1 parent 3eb0418 commit b99703f

File tree

7 files changed

+23
-7
lines changed

7 files changed

+23
-7
lines changed

Directory.Packages.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.3" />
1010
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.3" />
1111
<PackageVersion Include="Microsoft.Extensions.Options" Version="9.0.3" />
12-
<PackageVersion Include="Scrutor" Version="6.0.1" />
1312
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.24126.1" />
1413
<PackageVersion Include="System.IO.Abstractions" Version="22.0.12" />
1514
<PackageVersion Include="Visitor.NET" Version="4.1.2" />
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace HydraScript.Infrastructure.Dumping;
2+
3+
public static class DecoratorKey
4+
{
5+
public const string Value = "domain";
6+
}

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/HydraScript.Infrastructure.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<ItemGroup>
1616
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
1717
<PackageReference Include="Microsoft.Extensions.Options" />
18-
<PackageReference Include="Scrutor" />
1918
<PackageReference Include="System.IO.Abstractions" />
2019
</ItemGroup>
2120

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)