Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions AL2DBML.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AL2DBML.Application", "src\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AL2DBML.DI", "src\AL2DBML.DI\AL2DBML.DI.csproj", "{6F45FC15-7CA3-4F71-9900-3AE77ED9C14B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AL2DBLM.DBMLWriter", "src\DBMLWriter\AL2DBLM.DBMLWriter.csproj", "{D2033B53-9C03-47D9-BA96-2A59F5FDCC95}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -99,6 +101,18 @@ Global
{6F45FC15-7CA3-4F71-9900-3AE77ED9C14B}.Release|x64.Build.0 = Release|Any CPU
{6F45FC15-7CA3-4F71-9900-3AE77ED9C14B}.Release|x86.ActiveCfg = Release|Any CPU
{6F45FC15-7CA3-4F71-9900-3AE77ED9C14B}.Release|x86.Build.0 = Release|Any CPU
{D2033B53-9C03-47D9-BA96-2A59F5FDCC95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2033B53-9C03-47D9-BA96-2A59F5FDCC95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2033B53-9C03-47D9-BA96-2A59F5FDCC95}.Debug|x64.ActiveCfg = Debug|Any CPU
{D2033B53-9C03-47D9-BA96-2A59F5FDCC95}.Debug|x64.Build.0 = Debug|Any CPU
{D2033B53-9C03-47D9-BA96-2A59F5FDCC95}.Debug|x86.ActiveCfg = Debug|Any CPU
{D2033B53-9C03-47D9-BA96-2A59F5FDCC95}.Debug|x86.Build.0 = Debug|Any CPU
{D2033B53-9C03-47D9-BA96-2A59F5FDCC95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2033B53-9C03-47D9-BA96-2A59F5FDCC95}.Release|Any CPU.Build.0 = Release|Any CPU
{D2033B53-9C03-47D9-BA96-2A59F5FDCC95}.Release|x64.ActiveCfg = Release|Any CPU
{D2033B53-9C03-47D9-BA96-2A59F5FDCC95}.Release|x64.Build.0 = Release|Any CPU
{D2033B53-9C03-47D9-BA96-2A59F5FDCC95}.Release|x86.ActiveCfg = Release|Any CPU
{D2033B53-9C03-47D9-BA96-2A59F5FDCC95}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -110,5 +124,6 @@ Global
{DFD7C487-21C3-414D-B1B5-71A7923863B4} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{05BCFDA4-6B86-4105-9A52-6B4F9790069D} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{6F45FC15-7CA3-4F71-9900-3AE77ED9C14B} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{D2033B53-9C03-47D9-BA96-2A59F5FDCC95} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
EndGlobalSection
EndGlobal
32 changes: 32 additions & 0 deletions src/AL2DBML.Application/Helpers/OutputSchemaHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using AL2DBML.Core.Models;

namespace AL2DBML.Application.Helpers;

public static class OutputSchemaHelper
{
public static OutputSchema DeepCopy(OutputSchema schema) =>
new()
{
Enums = schema.Enums
.Select(e => new DBMLEnum { Name = e.Name, Values = [.. e.Values] })
.ToList(),
Tables = schema.Tables
.Select(t => new DBMLTable
{
Name = t.Name,
Fields = t.Fields
.Select(f => new DBMLColumn
{
Name = f.Name,
Type = f.Type,
IsPrimaryKey = f.IsPrimaryKey,
References = f.References?.ToArray(),
IsFlowfield = f.IsFlowfield,
CalcFormula = f.CalcFormula
})
.ToList()
})
.ToList()
};

}
1 change: 1 addition & 0 deletions src/AL2DBML.Application/Interfaces/IAlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public interface IAlParser
DBMLTable ParseTable(string alTableFileContent);
DBMLTable ParseTableExtension(string alTableExtensionFileContent);
DBMLColumn ParseField(string alFieldContent);
Comment thread
OGR-67 marked this conversation as resolved.
OutputSchema GetOutputSchema();
}
8 changes: 8 additions & 0 deletions src/AL2DBML.Application/Interfaces/IDBMLWriter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using AL2DBML.Core.Models;

namespace AL2DBML.Application.Interfaces;

public interface IDBMLWriter
{
Task<string> WriteDBMLAsync(OutputSchema outputSchema);
}
8 changes: 8 additions & 0 deletions src/AL2DBML.Application/Interfaces/ISchemaPostProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using AL2DBML.Core.Models;

namespace AL2DBML.Application.Interfaces;

public interface ISchemaPostProcessor
{
OutputSchema Process(OutputSchema schema);
}
1 change: 1 addition & 0 deletions src/AL2DBML.DI/AL2DBML.DI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ProjectReference Include="../AL2DBML.Application/AL2DBML.Application.csproj" />
<ProjectReference Include="../AL2DBML.Core/AL2DBML.Core.csproj" />
<ProjectReference Include="../AL2DBML.Parser/AL2DBML.Parser.csproj" />
<ProjectReference Include="../DBMLWriter/AL2DBLM.DBMLWriter.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/AL2DBML.DI/AL2DbmlServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public static class AL2DbmlServiceExtensions
public static IServiceCollection AddAL2Dbml(this IServiceCollection services)
=> services
.AddApplication()
.AddParser();
.AddParser()
.AddWriter();
}
15 changes: 15 additions & 0 deletions src/AL2DBML.DI/WriterServiceExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using AL2DBML.Application.Interfaces;
using AL2DBML.DBMLWriter;
using Microsoft.Extensions.DependencyInjection;

namespace AL2DBML.DI;

public static class WriterServiceExtensions
{
public static IServiceCollection AddWriter(this IServiceCollection services)
{
services.AddScoped<ISchemaPostProcessor, SchemaPostProcessor>();
services.AddScoped<IDBMLWriter, DBLMWriter>();
return services;
}
}
6 changes: 6 additions & 0 deletions src/AL2DBML.Parser/AlParser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
using AL2DBML.Application.Helpers;
using AL2DBML.Application.Interfaces;
using AL2DBML.Core.Enums;
using AL2DBML.Core.Models;
Expand Down Expand Up @@ -174,4 +175,9 @@ public DBMLColumn ParseField(string alFieldContent)
CalcFormula = calcFormula
};
}

public OutputSchema GetOutputSchema()
{
return OutputSchemaHelper.DeepCopy(_outputSchema);
}
Comment thread
OGR-67 marked this conversation as resolved.
}
3 changes: 1 addition & 2 deletions src/AL2DBML.Tests/AL2DBML.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
<ItemGroup>
<ProjectReference Include="../AL2DBML.Application/AL2DBML.Application.csproj" />
<ProjectReference Include="../AL2DBML.Core/AL2DBML.Core.csproj" />
<ProjectReference Include="../AL2DBML.Parser/AL2DBML.Parser.csproj" />
<ProjectReference Include="..\AL2DBML.DI\AL2DBML.DI.csproj" />
<ProjectReference Include="../AL2DBML.DI/AL2DBML.DI.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/AL2DBML.Tests/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public abstract class TestBase
{
protected IServiceProvider Services { get; }
protected IAlParser _parser { get; private set; }
protected IDBMLWriter _writer { get; private set; }

protected TestBase()
{
Expand All @@ -15,6 +16,7 @@ protected TestBase()
.BuildServiceProvider();

_parser = Services.GetRequiredService<IAlParser>();
_writer = Services.GetRequiredService<IDBMLWriter>();
}

protected void ResetParser()
Expand Down
Loading
Loading