A database based on .net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.2 KiB

// Author: Gockner, Simon
// Created: 2020-02-10
// Copyright(c) 2020 SimonG. All Rights Reserved.
using System.Threading.Tasks;
using GBase.Api.Services;
using GBase.Client.Factories;
using GBase.Client.Interfaces;
using GBase.Client.Services.Factories;
namespace GBase.Client
{
/// <summary>
/// A client for the GBase
/// </summary>
public class GBaseClient : IGBaseClient //TODO: Add logging?
{
/// <summary>
/// A client for the GBase
/// </summary>
/// <param name="settings">The <see cref="IGBaseClientSettings"/> for this client</param>
/// <param name="gBaseServiceFactory">The <see cref="IGBaseServiceFactory"/></param>
/// <param name="gBaseTableServiceFactory">The <see cref="IGBaseTableServiceFactory"/></param>
/// <param name="gBaseEntryServiceFactory">The <see cref="IGBaseEntryServiceFactory"/></param>
public GBaseClient(IGBaseClientSettings settings, IGBaseServiceFactory gBaseServiceFactory, IGBaseTableServiceFactory gBaseTableServiceFactory, IGBaseEntryServiceFactory gBaseEntryServiceFactory)
{
GBase = gBaseServiceFactory.Create(settings.Protocol, settings.ServerProtocolGBaseEndpointAddress);
GBaseTable = gBaseTableServiceFactory.Create(settings.Protocol, settings.ServerProtocolGBaseTableEndpointAddress);
GBaseEntry = gBaseEntryServiceFactory.Create(settings.Protocol, settings.ServerProtocolGBaseEntryEndpointAddress);
}
/// <summary>
/// Functions of the GBase
/// </summary>
public IGBaseService GBase { get; }
/// <summary>
/// Functions of the GBaseTable
/// </summary>
public IGBaseTableService GBaseTable { get; }
/// <summary>
/// Functions of the GBaseEntry
/// </summary>
public IGBaseEntryService GBaseEntry { get; }
/// <summary>
/// Dispose used resources asynchronously
/// </summary>
/// <returns>A <see cref="ValueTask"/> to await</returns>
public async ValueTask DisposeAsync()
{
await GBase.DisposeAsync();
await GBaseTable.DisposeAsync();
await GBaseEntry.DisposeAsync();
}
}
}