diff --git a/src/Deveel.Webhooks.Service.EntityFramework/Deveel.Webhooks.EntityFramework.xml b/src/Deveel.Webhooks.Service.EntityFramework/Deveel.Webhooks.EntityFramework.xml
index 15a6196..c5fb7fb 100644
--- a/src/Deveel.Webhooks.Service.EntityFramework/Deveel.Webhooks.EntityFramework.xml
+++ b/src/Deveel.Webhooks.Service.EntityFramework/Deveel.Webhooks.EntityFramework.xml
@@ -320,6 +320,12 @@
The type of the entity to use
+
+
+ Gets the entity type to be used to store the results of
+ webhook deliveries in the database.
+
+
Gets the that is used to
@@ -345,6 +351,25 @@
Returns the current instance of the builder for chaining.
+
+
+ Registers the given type of DB context to be used for
+ backing the storage of webhook subscriptions.
+
+
+ The type of the to use.
+
+
+ A configuration action that receives an instance of
+ that can be used to configure the options of the context.
+
+
+ An optional value that specifies the lifetime of the context.
+
+
+ Returns the current instance of the builder for chaining.
+
+
Registers the default type of DB context to be used for
diff --git a/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookStorageBuilder.cs b/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookStorageBuilder.cs
index e037277..36875f1 100644
--- a/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookStorageBuilder.cs
+++ b/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookStorageBuilder.cs
@@ -35,6 +35,10 @@ internal EntityWebhookStorageBuilder(WebhookSubscriptionBuilder b
AddDefaultStorage();
}
+ ///
+ /// Gets the entity type to be used to store the results of
+ /// webhook deliveries in the database.
+ ///
public Type? ResultType { get; private set; }
///
@@ -90,6 +94,39 @@ public EntityWebhookStorageBuilder UseContext(Action
+ /// Registers the given type of DB context to be used for
+ /// backing the storage of webhook subscriptions.
+ ///
+ ///
+ /// The type of the to use.
+ ///
+ ///
+ /// A configuration action that receives an instance of
+ /// that can be used to configure the options of the context.
+ ///
+ ///
+ /// An optional value that specifies the lifetime of the context.
+ ///
+ ///
+ /// Returns the current instance of the builder for chaining.
+ ///
+ public EntityWebhookStorageBuilder UseContext(Action options, ServiceLifetime lifetime = ServiceLifetime.Scoped)
+ where TContext : WebhookDbContext {
+ var factory = (IServiceProvider sp, DbContextOptionsBuilder builder) => {
+ var tenantInfo = sp.GetService()?.TenantInfo;
+ options(tenantInfo, builder);
+ };
+
+ if (typeof(TContext) != typeof(WebhookDbContext)) {
+ Services.AddDbContext(factory, lifetime);
+ } else {
+ Services.AddDbContext(factory, lifetime);
+ }
+
+ return this;
+ }
+
///
/// Registers the default type of DB context to be used for
/// backing the storage of webhook subscriptions.
@@ -125,6 +162,23 @@ public EntityWebhookStorageBuilder UseSubscriptionStore()
return this;
}
+ ///
+ /// Configures the storage to use the given type of result.
+ ///
+ ///
+ /// The type of the result to use, that must be derived from
+ /// the type.
+ ///
+ ///
+ /// Returns the current instance of the builder for chaining.
+ ///
+ ///
+ /// Thrown when the given is null.
+ ///
+ ///
+ /// Thrown when the given is not derived from
+ /// .
+ ///
public EntityWebhookStorageBuilder UseResultType(Type type) {
if (type is null)
throw new ArgumentNullException(nameof(type));
@@ -137,6 +191,10 @@ public EntityWebhookStorageBuilder UseResultType(Type type) {
return this;
}
+ public EntityWebhookStorageBuilder UseResult()
+ where TResult : DbWebhookDeliveryResult
+ => UseResultType(typeof(TResult));
+
public EntityWebhookStorageBuilder UseResultStore(Type storeType) {
if (ResultType == null)
throw new InvalidOperationException("No result type was specified for the storage");