.NET Client
There are two .NET client libraries available:
- Dangl.AVACloud.Client.Public on the public NuGet repository
- Dangl.AVACloud.Client on the
dangl-ava
MyGet feed for DanglIT customers
GitHub Example
On GitHub, DanglIT is providing an example for the AVACloud .NET Client: https://github.com/Dangl-IT/Dangl.AVACloud.Example-DotNet
Accessing the NuGet Package
All required packages are available on the public NuGet feed. Beta packages are, however, only on a custom MyGet feed available at: https://www.myget.org/feed/Packages/dangl
The feed itself is available at:
https://www.myget.org/F/dangl/api/v3/index.json
(NuGet V3, Visual Studio 2015+)https://www.myget.org/F/dangl/api/v2
Integrating libraries via NuGet feeds is the preferred approach in contrast to directly referencing dlls.
Please see the official NuGet documentation on how to configure NuGet feeds on your development or build machines.
Additionally, I'v written a blog post that goes into detail on how to setup and consume private NuGet feeds.
Additionally, all DanglIT packages are available on the internal MyGet feed.
For customers, there is also a private MyGet feed available. Please see the documentation for how to access it.
Example Code
There are two easy steps to set up Api access:
First, create a client factory. This is marked as static to showcase that you can easily share a single instance
of the clients as singleton throughout your app lifecycle. In fact, this is the recommended way to prevent multiple
instances of the System.Net.HttpClient
class to cause TCP connection exhaustion in high-traffic scenarios. Internally,
the HttpClientFactory
is used to manage the lifetime of HttpClient
s.
Please use the values for your generated client to replace ClientId
and ClientSecret
. If you have not yet registered one,
please register a new account and create a client.
internal static class ClientFactory
{
public static AvaCloudClientFactory Factory { get; }
static ClientFactory()
{
Factory = GetFactory();
}
private static AvaCloudClientFactory GetFactory()
{
var avaCloudConfig = new AvaCloudConfiguration("ClientId", "ClientSecret");
var factory = new AvaCloudClientFactory(avaCloudConfig);
return factory;
}
}
In the second part, we simply access the factory to get the GaebConversionClient
and perform a conversion:
[Fact]
public async Task CanGenerateWithFactoryAndConvertGaebToGaeb()
{
var factory = ClientFactory.Factory;
var gaebConversionClient = factory.GaebConversionClient;
var sourceGaebFile = TestFilesFactory.GetTestFileStream(TestFile.GaebXmlEnMinimal);
var fileParam = new FileParameter(sourceGaebFile);
var conversion = await gaebConversionClient.ConvertToGaebAsync(fileParam, DestinationGaebType.Gaeb2000, DestinationGaebExchangePhase.None, true);
// The code below is for an xUnit unit test and demonstrates how to verify the conversion was successful
Assert.Equal(200, conversion.StatusCode);
// Customers that also have access to the GAEB & AVA .Net Libraries can read the native GAEB file like this:
var gaebFile = GAEB.Reader.GAEBReader.ReadGaeb(conversion.Stream);
Assert.Equal(GAEB.GaebFileVersion.Gaeb2000, gaebFile.Version);
}
Old TLS Versions
The AVACloud API requires at least TLS 1.2. If you are using .NET Framework 4.5 or older, you need to explicitly enable TLS 1.2 or newer. If you experience errors, you can configure TLS 1.2 with this global setting:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;