diff --git a/src/Leanetec.EConnect.Client/Client.cs b/src/Leanetec.EConnect.Client/Client.cs new file mode 100644 index 0000000..e63447a --- /dev/null +++ b/src/Leanetec.EConnect.Client/Client.cs @@ -0,0 +1,31 @@ +using MediatR; +using Microsoft.Extensions.DependencyInjection; + +namespace Leanetec.EConnect.Client; + +/// +/// Provides a lazily initialized for accessing the EConnect client services, +/// including an instance for sending and publishing messages. +/// +public static class Client +{ + /// + /// Lazily initializes the that registers and builds the EConnect client services. + /// + private static readonly Lazy _serviceProvider = new(() => + { + var services = new ServiceCollection(); + services.AddEConnectClient(); + return services.BuildServiceProvider(); + }); + + /// + /// Gets the initialized that provides access to registered EConnect client services. + /// + public static IServiceProvider Provider => _serviceProvider.Value; + + /// + /// Gets the instance used for sending commands, queries, and publishing events within the EConnect client. + /// + public static IMediator Mediator => Provider.GetRequiredService(); +} \ No newline at end of file