Skip to content

Commit

Permalink
#79 - enum'ы вместо строк как ключи для DI +semver:skip (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stepami authored Sep 20, 2024
1 parent a9d289a commit c1bd557
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace HydraScript.Application.CodeGeneration;

public enum CodeGeneratorType
{
General = 1,

Expression = 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public static IServiceCollection AddCodeGeneration(this IServiceCollection servi
services.AddSingleton<IValueDtoConverter, ValueDtoConverter>();
services.AddKeyedSingleton<
IVisitor<IAbstractSyntaxTreeNode, AddressedInstructions>,
InstructionProvider>("instructions");
InstructionProvider>(CodeGeneratorType.General);
services.AddKeyedSingleton<
IVisitor<IAbstractSyntaxTreeNode, AddressedInstructions>,
ExpressionInstructionProvider>("expression-instructions");
ExpressionInstructionProvider>(CodeGeneratorType.Expression);
return services;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class InstructionProvider : VisitorBase<IAbstractSyntaxTreeNode, Addres

public InstructionProvider(
IValueDtoConverter valueDtoConverter,
[FromKeyedServices("expression-instructions")]
[FromKeyedServices(CodeGeneratorType.Expression)]
IVisitor<IAbstractSyntaxTreeNode, AddressedInstructions> expressionVisitor)
{
_valueDtoConverter = valueDtoConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class CodeGenerator : ICodeGenerator

public CodeGenerator(
IStaticAnalyzer staticAnalyzer,
[FromKeyedServices("instructions")]
[FromKeyedServices(CodeGeneratorType.General)]
IVisitor<IAbstractSyntaxTreeNode, AddressedInstructions> visitor)
{
_staticAnalyzer = staticAnalyzer;
Expand Down

0 comments on commit c1bd557

Please sign in to comment.