-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from fiskaltrust/user/tsc/factories
Add helper packages to simplify IPOS creation via different communication channels
- Loading branch information
Showing
38 changed files
with
1,401 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<PackageReference Include="Nerdbank.GitVersioning"> | ||
<Version>3.0.50</Version> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29521.150 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{396D771A-5085-49F4-B020-389C901C75D3}" | ||
ProjectSection(SolutionItems) = preProject | ||
Directory.Build.props = Directory.Build.props | ||
README.md = README.md | ||
version.json = version.json | ||
EndProjectSection | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{18766606-E68D-44CC-B89A-5807F901D943}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{4A4977D1-0B9A-44F9-B4A3-3D08FBB58D14}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "fiskaltrust.interface", "src\fiskaltrust.ifPOS\fiskaltrust.interface.csproj", "{ED0862F3-D1A0-4246-A22D-937F471647CE}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "fiskaltrust.Middleware.Interface.Tests", "test\fiskaltrust.ifPOS.Tests\fiskaltrust.Middleware.Interface.Tests.csproj", "{B4ECE1C6-E1F3-4F54-98B8-B588D9DB52D9}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Client", "Client", "{7CCEF987-3E5A-48D0-9D69-708C62526829}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "fiskaltrust.Middleware.Interface.Client.Grpc", "src\fiskaltrust.Middleware.Interface.Client.Grpc\fiskaltrust.Middleware.Interface.Client.Grpc.csproj", "{5274E790-A7AD-4360-8613-72E9CCDF43CE}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "fiskaltrust.Middleware.Interface.Client.Http", "src\fiskaltrust.Middleware.Interface.Client.Http\fiskaltrust.Middleware.Interface.Client.Http.csproj", "{71C15B88-ACE8-4926-AA1D-85ECA2199AE3}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "fiskaltrust.Middleware.Interface.Client.Soap", "src\fiskaltrust.Middleware.Interface.Client.Soap\fiskaltrust.Middleware.Interface.Client.Soap.csproj", "{FB69506F-4B31-4F9E-90EC-078D035A17EB}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fiskaltrust.Middleware.Interface.Client.Shared", "src\fiskaltrust.Middleware.Interface.Client.Shared\fiskaltrust.Middleware.Interface.Client.Shared.csproj", "{4CF9D784-E218-414D-8A14-56D514C0FBA9}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fiskaltrust.Middleware.Interface.Client.Tests", "test\fiskaltrust.Middleware.Interface.Client.Tests\fiskaltrust.Middleware.Interface.Client.Tests.csproj", "{8D5E806B-39EF-4FCD-AD59-5AB710F5D8BB}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{ED0862F3-D1A0-4246-A22D-937F471647CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{ED0862F3-D1A0-4246-A22D-937F471647CE}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{ED0862F3-D1A0-4246-A22D-937F471647CE}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{ED0862F3-D1A0-4246-A22D-937F471647CE}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{B4ECE1C6-E1F3-4F54-98B8-B588D9DB52D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B4ECE1C6-E1F3-4F54-98B8-B588D9DB52D9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B4ECE1C6-E1F3-4F54-98B8-B588D9DB52D9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B4ECE1C6-E1F3-4F54-98B8-B588D9DB52D9}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{5274E790-A7AD-4360-8613-72E9CCDF43CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5274E790-A7AD-4360-8613-72E9CCDF43CE}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5274E790-A7AD-4360-8613-72E9CCDF43CE}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5274E790-A7AD-4360-8613-72E9CCDF43CE}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{71C15B88-ACE8-4926-AA1D-85ECA2199AE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{71C15B88-ACE8-4926-AA1D-85ECA2199AE3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{71C15B88-ACE8-4926-AA1D-85ECA2199AE3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{71C15B88-ACE8-4926-AA1D-85ECA2199AE3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{FB69506F-4B31-4F9E-90EC-078D035A17EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{FB69506F-4B31-4F9E-90EC-078D035A17EB}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{FB69506F-4B31-4F9E-90EC-078D035A17EB}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{FB69506F-4B31-4F9E-90EC-078D035A17EB}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4CF9D784-E218-414D-8A14-56D514C0FBA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4CF9D784-E218-414D-8A14-56D514C0FBA9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4CF9D784-E218-414D-8A14-56D514C0FBA9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4CF9D784-E218-414D-8A14-56D514C0FBA9}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{8D5E806B-39EF-4FCD-AD59-5AB710F5D8BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8D5E806B-39EF-4FCD-AD59-5AB710F5D8BB}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8D5E806B-39EF-4FCD-AD59-5AB710F5D8BB}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8D5E806B-39EF-4FCD-AD59-5AB710F5D8BB}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{ED0862F3-D1A0-4246-A22D-937F471647CE} = {18766606-E68D-44CC-B89A-5807F901D943} | ||
{B4ECE1C6-E1F3-4F54-98B8-B588D9DB52D9} = {4A4977D1-0B9A-44F9-B4A3-3D08FBB58D14} | ||
{7CCEF987-3E5A-48D0-9D69-708C62526829} = {18766606-E68D-44CC-B89A-5807F901D943} | ||
{5274E790-A7AD-4360-8613-72E9CCDF43CE} = {7CCEF987-3E5A-48D0-9D69-708C62526829} | ||
{71C15B88-ACE8-4926-AA1D-85ECA2199AE3} = {7CCEF987-3E5A-48D0-9D69-708C62526829} | ||
{FB69506F-4B31-4F9E-90EC-078D035A17EB} = {7CCEF987-3E5A-48D0-9D69-708C62526829} | ||
{4CF9D784-E218-414D-8A14-56D514C0FBA9} = {7CCEF987-3E5A-48D0-9D69-708C62526829} | ||
{8D5E806B-39EF-4FCD-AD59-5AB710F5D8BB} = {4A4977D1-0B9A-44F9-B4A3-3D08FBB58D14} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {3CAE7E81-C6A5-44FA-8E98-F9207561129F} | ||
EndGlobalSection | ||
EndGlobal |
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
src/fiskaltrust.Middleware.Interface.Client.Grpc/GrpcPosFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using fiskaltrust.ifPOS.v1; | ||
using fiskaltrust.Middleware.Interface.Client.Shared; | ||
using System.Threading.Tasks; | ||
|
||
namespace fiskaltrust.Middleware.Interface.Client.Grpc | ||
{ | ||
public static class GrpcPosFactory | ||
{ | ||
public static async Task<IPOS> CreatePosAsync(GrpcPosOptions options) | ||
{ | ||
var connectionhandler = new GrpcProxyConnectionHandler<IPOS>(options); | ||
|
||
if (options.RetryPolicyOptions != null) | ||
{ | ||
var retryPolicyHelper = new RetryPolicyHandler<IPOS>(options.RetryPolicyOptions, connectionhandler); | ||
return new PosRetryProxyClient(retryPolicyHelper); | ||
} | ||
else | ||
{ | ||
return await connectionhandler.GetProxyAsync(); | ||
} | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/fiskaltrust.Middleware.Interface.Client.Grpc/GrpcPosOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using fiskaltrust.Middleware.Interface.Client.Shared; | ||
using Grpc.Core; | ||
|
||
namespace fiskaltrust.Middleware.Interface.Client.Grpc | ||
{ | ||
public class GrpcPosOptions : PosOptions | ||
{ | ||
public ChannelCredentials ChannelCredentials { get; set; } = ChannelCredentials.Insecure; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/fiskaltrust.Middleware.Interface.Client.Grpc/GrpcProxyConnectionHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using fiskaltrust.Middleware.Interface.Client.Shared.RetryLogic.Interfaces; | ||
using Grpc.Core; | ||
using ProtoBuf.Grpc.Client; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace fiskaltrust.Middleware.Interface.Client.Grpc | ||
{ | ||
internal class GrpcProxyConnectionHandler<T> : IProxyConnectionHandler<T> where T : class | ||
{ | ||
private T _proxy; | ||
private Channel _channel; | ||
private readonly GrpcPosOptions _options; | ||
|
||
public GrpcProxyConnectionHandler(GrpcPosOptions options) | ||
{ | ||
_options = options; | ||
} | ||
|
||
public Task ReconnectAsync() | ||
{ | ||
if (_proxy != null && _channel.State == ChannelState.Ready) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
_channel = new Channel(_options.Url.Host, _options.Url.Port, _options.ChannelCredentials); | ||
_proxy = _channel.CreateGrpcService<T>(); | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
public async Task ForceReconnectAsync() | ||
{ | ||
try | ||
{ | ||
await _channel.ShutdownAsync(); | ||
} | ||
catch | ||
{ | ||
// We can ignore the case when shutdown failed | ||
} | ||
_channel = new Channel(_options.Url.Host, _options.Url.Port, ChannelCredentials.Insecure); | ||
_proxy = _channel.CreateGrpcService<T>(); | ||
} | ||
|
||
public async Task<T> GetProxyAsync() | ||
{ | ||
if (_proxy == null || _channel.State != ChannelState.Ready) | ||
{ | ||
await ReconnectAsync(); | ||
} | ||
|
||
return _proxy; | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...rust.Middleware.Interface.Client.Grpc/fiskaltrust.Middleware.Interface.Client.Grpc.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="fiskaltrust.interface" Version="1.3.0-rc1" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="6.0.8" /> | ||
<PackageReference Include="Grpc.Core" Version="2.28.1" /> | ||
<PackageReference Include="protobuf-net.Grpc.Native" Version="1.0.37" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\fiskaltrust.Middleware.Interface.Client.Shared\fiskaltrust.Middleware.Interface.Client.Shared.csproj"> | ||
<PrivateAssets>all</PrivateAssets> | ||
</ProjectReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<_PackageFiles Include="$(OutputPath)\net461\fiskaltrust.Middleware.Interface.Client.Shared.dll"> | ||
<BuildAction>None</BuildAction> | ||
<PackagePath>lib\net461\</PackagePath> | ||
</_PackageFiles> | ||
<_PackageFiles Include="$(OutputPath)\netstandard2.0\fiskaltrust.Middleware.Interface.Client.Shared.dll"> | ||
<BuildAction>None</BuildAction> | ||
<PackagePath>lib\netstandard2.0\</PackagePath> | ||
</_PackageFiles> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<PackageId>fiskaltrust.Middleware.Interface.Client.Grpc</PackageId> | ||
<Authors>fiskaltrust</Authors> | ||
<Company>fiskaltrust</Company> | ||
<PackageLicenseUrl>https://github.com/fiskaltrust/middleware-interface-dotnet/LICENSE</PackageLicenseUrl> | ||
<PackageProjectUrl>https://github.com/fiskaltrust/middleware-interface-dotnet</PackageProjectUrl> | ||
<PackageIconUrl>https://portal.fiskaltrust.at/Content/favicons/favicon-64x64.png</PackageIconUrl> | ||
<Description>An optional helper implementation to simplify the usage of the fiskaltrust Middleware interface via gRPC.</Description> | ||
<Copyright>Copyright 2020</Copyright> | ||
<PackageTags>fiskaltrust interface</PackageTags> | ||
<AssemblyCompany>fiskaltrust</AssemblyCompany> | ||
<AssemblyProduct>fiskaltrust.Middleware.Interface.Grpc</AssemblyProduct> | ||
</PropertyGroup> | ||
|
||
</Project> |
18 changes: 18 additions & 0 deletions
18
src/fiskaltrust.Middleware.Interface.Client.Http/Helpers/XmlSerializationHelpers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.IO; | ||
using System.Xml.Serialization; | ||
|
||
namespace fiskaltrust.Middleware.Interface.Client.Http.Helpers | ||
{ | ||
internal static class XmlSerializationHelpers | ||
{ | ||
public static string Serialize(object inputObject) | ||
{ | ||
using (var writer = new StringWriter()) | ||
{ | ||
new XmlSerializer(inputObject.GetType()).Serialize(writer, inputObject); | ||
return writer.ToString(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.