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
14 changes: 14 additions & 0 deletions src/Linq2OData.Generator/ClientGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ private void GenerateClientCode()
var templateHelperText = new ClientHelperTemplate(request).TransformText();
AddFile("Client", request.Name + "Helpers.cs", templateHelperText);
}

GenerateActionsCode();
}

private void GenerateActionsCode()
{
foreach (var clientMetadata in request.Metadata)
{
if (!clientMetadata.Metadata.Schemas.Any(s => s.Functions.Any()))
continue;

var actionsText = new ActionsTemplate(request, clientMetadata, (ODataVersion)version!).TransformText();
AddFile("Client", clientMetadata.ActionsClassName + ".cs", actionsText);
}
}

private void GenerateTypesCode()
Expand Down
9 changes: 9 additions & 0 deletions src/Linq2OData.Generator/Linq2OData.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
</ItemGroup>

<ItemGroup>
<Compile Update="Templates\Client\ActionsTemplate.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>ActionsTemplate.tt</DependentUpon>
</Compile>
<Compile Update="Templates\Client\ClientHelperTemplate.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand Down Expand Up @@ -56,6 +61,10 @@


<ItemGroup>
<None Update="Templates\Client\ActionsTemplate.tt">
<Generator>TextTemplatingFilePreprocessor</Generator>
<LastGenOutput>ActionsTemplate.cs</LastGenOutput>
</None>
<None Update="Templates\Client\ClientHelperTemplate.tt">
<Generator>TextTemplatingFilePreprocessor</Generator>
<LastGenOutput>ClientHelperTemplate.cs</LastGenOutput>
Expand Down
3 changes: 3 additions & 0 deletions src/Linq2OData.Generator/MetadataExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ private static string MapEdmTypeToCSharp(string edmType)
internal string JsonName => $"{navigation.NamespaceName}_Json";
internal string HelperName => $"{navigation.NamespaceName}_Helper";
internal string ServiceName => $"{navigation.NamespaceName}_Service";
internal string ActionsClassName => $"{navigation.NamespaceName}_Actions";
internal string ActionsPropertyName => navigation.NamespaceName;
internal string ActionsFieldName => $"{Helpers.ToCamelCaseVariable(navigation.NamespaceName)}";

internal string MetadataAsJson => System.Text.Json.JsonSerializer.Serialize(navigation.Metadata);

Expand Down
Loading
Loading