From c135976db1b78f2944b43c16dd7a906a1f66f973 Mon Sep 17 00:00:00 2001
From: thefringeninja <495495+thefringeninja@users.noreply.github.com>
Date: Tue, 27 Oct 2020 14:11:54 +0100
Subject: [PATCH] add connection string overloads for di extensions
---
...ationsClientServiceCollectionExtensions.cs | 20 +++++++++++--
...SubscriptionsClientCollectionExtensions.cs | 22 ++++++++++++--
...ionManagementClientCollectionExtensions.cs | 21 +++++++++++--
...tStoreClientServiceCollectionExtensions.cs | 24 +++++++++++++--
...serManagementClientCollectionExtensions.cs | 30 ++++++++++++++-----
5 files changed, 102 insertions(+), 15 deletions(-)
diff --git a/src/EventStore.Client.Operations/EventStoreOperationsClientServiceCollectionExtensions.cs b/src/EventStore.Client.Operations/EventStoreOperationsClientServiceCollectionExtensions.cs
index b18d9a89c..f2563da51 100644
--- a/src/EventStore.Client.Operations/EventStoreOperationsClientServiceCollectionExtensions.cs
+++ b/src/EventStore.Client.Operations/EventStoreOperationsClientServiceCollectionExtensions.cs
@@ -22,6 +22,7 @@ public static class EventStoreOperationsClientServiceCollectionExtensions {
///
///
///
+ ///
public static IServiceCollection AddEventStoreOperationsClient(this IServiceCollection services, Uri address,
Func? createHttpMessageHandler = null)
=> services.AddEventStoreOperationsClient(options => {
@@ -37,12 +38,27 @@ public static IServiceCollection AddEventStoreOperationsClient(this IServiceColl
///
///
public static IServiceCollection AddEventStoreOperationsClient(this IServiceCollection services,
- Action? configureOptions = null) {
+ Action? configureOptions = null) =>
+ services.AddEventStoreOperationsClient(new EventStoreClientSettings(), configureOptions);
+
+ ///
+ /// Adds an to the .
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IServiceCollection AddEventStoreOperationsClient(this IServiceCollection services,
+ string connectionString, Action? configureOptions = null) =>
+ services.AddEventStoreOperationsClient(EventStoreClientSettings.Create(connectionString), configureOptions);
+
+ private static IServiceCollection AddEventStoreOperationsClient(this IServiceCollection services,
+ EventStoreClientSettings options, Action? configureOptions) {
if (services == null) {
throw new ArgumentNullException(nameof(services));
}
- var options = new EventStoreClientSettings();
configureOptions?.Invoke(options);
services.TryAddSingleton(provider => {
diff --git a/src/EventStore.Client.PersistentSubscriptions/EventStorePersistentSubscriptionsClientCollectionExtensions.cs b/src/EventStore.Client.PersistentSubscriptions/EventStorePersistentSubscriptionsClientCollectionExtensions.cs
index c6dec543f..a9164d660 100644
--- a/src/EventStore.Client.PersistentSubscriptions/EventStorePersistentSubscriptionsClientCollectionExtensions.cs
+++ b/src/EventStore.Client.PersistentSubscriptions/EventStorePersistentSubscriptionsClientCollectionExtensions.cs
@@ -20,6 +20,7 @@ public static class EventStorePersistentSubscriptionsClientCollectionExtensions
///
///
///
+ ///
public static IServiceCollection AddEventStorePersistentSubscriptionsClient(this IServiceCollection services,
Uri address,
Func? createHttpMessageHandler = null)
@@ -36,12 +37,29 @@ public static IServiceCollection AddEventStorePersistentSubscriptionsClient(this
///
///
public static IServiceCollection AddEventStorePersistentSubscriptionsClient(this IServiceCollection services,
- Action? configureSettings = null) {
+ Action? configureSettings = null) =>
+ services.AddEventStorePersistentSubscriptionsClient(new EventStoreClientSettings(),
+ configureSettings);
+
+ ///
+ /// Adds an to the .
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IServiceCollection AddEventStorePersistentSubscriptionsClient(this IServiceCollection services,
+ string connectionString, Action? configureSettings = null) =>
+ services.AddEventStorePersistentSubscriptionsClient(EventStoreClientSettings.Create(connectionString),
+ configureSettings);
+
+ private static IServiceCollection AddEventStorePersistentSubscriptionsClient(this IServiceCollection services,
+ EventStoreClientSettings settings, Action? configureSettings) {
if (services == null) {
throw new ArgumentNullException(nameof(services));
}
- var settings = new EventStoreClientSettings();
configureSettings?.Invoke(settings);
services.TryAddSingleton(provider => {
diff --git a/src/EventStore.Client.ProjectionManagement/EventStoreProjectionManagementClientCollectionExtensions.cs b/src/EventStore.Client.ProjectionManagement/EventStoreProjectionManagementClientCollectionExtensions.cs
index 492252a02..19ca8f948 100644
--- a/src/EventStore.Client.ProjectionManagement/EventStoreProjectionManagementClientCollectionExtensions.cs
+++ b/src/EventStore.Client.ProjectionManagement/EventStoreProjectionManagementClientCollectionExtensions.cs
@@ -20,6 +20,7 @@ public static class EventStoreProjectionManagementClientCollectionExtensions {
///
///
///
+ ///
public static IServiceCollection AddEventStoreProjectionManagementClient(this IServiceCollection services,
Uri address,
Func? createHttpMessageHandler = null)
@@ -36,12 +37,28 @@ public static IServiceCollection AddEventStoreProjectionManagementClient(this IS
///
///
public static IServiceCollection AddEventStoreProjectionManagementClient(this IServiceCollection services,
- Action? configureSettings = null) {
+ Action? configureSettings = null) =>
+ services.AddEventStoreProjectionManagementClient(new EventStoreClientSettings(), configureSettings);
+
+ ///
+ /// Adds an to the .
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IServiceCollection AddEventStoreProjectionManagementClient(this IServiceCollection services,
+ string connectionString, Action? configureSettings = null) =>
+ services.AddEventStoreProjectionManagementClient(EventStoreClientSettings.Create(connectionString),
+ configureSettings);
+
+ private static IServiceCollection AddEventStoreProjectionManagementClient(this IServiceCollection services,
+ EventStoreClientSettings settings, Action? configureSettings) {
if (services == null) {
throw new ArgumentNullException(nameof(services));
}
- var settings = new EventStoreClientSettings();
configureSettings?.Invoke(settings);
services.TryAddSingleton(provider => {
diff --git a/src/EventStore.Client.Streams/EventStoreClientServiceCollectionExtensions.cs b/src/EventStore.Client.Streams/EventStoreClientServiceCollectionExtensions.cs
index becc511c7..6be63701b 100644
--- a/src/EventStore.Client.Streams/EventStoreClientServiceCollectionExtensions.cs
+++ b/src/EventStore.Client.Streams/EventStoreClientServiceCollectionExtensions.cs
@@ -20,6 +20,7 @@ public static class EventStoreClientServiceCollectionExtensions {
///
///
///
+ ///
public static IServiceCollection AddEventStoreClient(this IServiceCollection services, Uri address,
Func? createHttpMessageHandler = null)
=> services.AddEventStoreClient(options => {
@@ -36,12 +37,31 @@ public static IServiceCollection AddEventStoreClient(this IServiceCollection ser
///
///
public static IServiceCollection AddEventStoreClient(this IServiceCollection services,
- Action? configureSettings = null) {
+ Action? configureSettings = null) =>
+ services.AddEventStoreClient(new EventStoreClientSettings(), configureSettings);
+
+
+ ///
+ /// Adds an to the .
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IServiceCollection AddEventStoreClient(this IServiceCollection services,
+ string connectionString, Action? configureSettings = null) {
if (services == null) {
throw new ArgumentNullException(nameof(services));
}
- var settings = new EventStoreClientSettings();
+ return services.AddEventStoreClient(EventStoreClientSettings.Create(connectionString), configureSettings);
+ }
+
+
+ private static IServiceCollection AddEventStoreClient(this IServiceCollection services,
+ EventStoreClientSettings settings,
+ Action? configureSettings) {
configureSettings?.Invoke(settings);
services.TryAddSingleton(provider => {
diff --git a/src/EventStore.Client.UserManagement/EventStoreUserManagementClientCollectionExtensions.cs b/src/EventStore.Client.UserManagement/EventStoreUserManagementClientCollectionExtensions.cs
index 223e9c87e..79756766c 100644
--- a/src/EventStore.Client.UserManagement/EventStoreUserManagementClientCollectionExtensions.cs
+++ b/src/EventStore.Client.UserManagement/EventStoreUserManagementClientCollectionExtensions.cs
@@ -20,9 +20,9 @@ public static class EventStoreUserManagementClientCollectionExtensions {
///
///
///
+ ///
public static IServiceCollection AddEventStoreUserManagementClient(this IServiceCollection services,
- Uri address,
- Func? createHttpMessageHandler = null)
+ Uri address, Func? createHttpMessageHandler = null)
=> services.AddEventStoreUserManagementClient(options => {
options.ConnectivitySettings.Address = address;
options.CreateHttpMessageHandler = createHttpMessageHandler;
@@ -32,23 +32,39 @@ public static IServiceCollection AddEventStoreUserManagementClient(this IService
/// Adds an to the .
///
///
+ ///
///
///
///
public static IServiceCollection AddEventStoreUserManagementClient(this IServiceCollection services,
- Action? configureSettings = null) {
+ string connectionString, Action? configureSettings = null)
+ => services.AddEventStoreUserManagementClient(EventStoreClientSettings.Create(connectionString),
+ configureSettings);
+
+
+ ///
+ /// Adds an to the .
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IServiceCollection AddEventStoreUserManagementClient(this IServiceCollection services,
+ Action? configureSettings = null) =>
+ services.AddEventStoreUserManagementClient(new EventStoreClientSettings(), configureSettings);
+
+ private static IServiceCollection AddEventStoreUserManagementClient(this IServiceCollection services,
+ EventStoreClientSettings settings, Action? configureSettings = null) {
+ configureSettings?.Invoke(settings);
if (services == null) {
throw new ArgumentNullException(nameof(services));
}
- var settings = new EventStoreClientSettings();
- configureSettings?.Invoke(settings);
-
services.TryAddSingleton(provider => {
settings.LoggerFactory ??= provider.GetService();
settings.Interceptors ??= provider.GetServices();
- return new EventStoreUserManagementClient(settings);
+ return new EventStoreUserManagementClient(new EventStoreClientSettings());
});
return services;