Commit 9de285b5 authored by yangxiaodong's avatar yangxiaodong

modify CapOptions Extension to support multiple extensions.

parent 5583f6af
using System;
using System.Collections.Generic;
namespace DotNetCore.CAP
{
......@@ -7,7 +8,7 @@ namespace DotNetCore.CAP
/// </summary>
public class CapOptions
{
internal ICapOptionsExtension Extension { get; private set; }
internal IList<ICapOptionsExtension> Extensions { get; private set; }
/// <summary>
/// Default value for polling delay timeout, in seconds.
......@@ -23,6 +24,7 @@ namespace DotNetCore.CAP
{
CronExp = DefaultCronExp;
PollingDelay = DefaultPollingDelay;
Extensions = new List<ICapOptionsExtension>();
}
/// <summary>
......@@ -41,7 +43,10 @@ namespace DotNetCore.CAP
/// <param name="extension"></param>
public void RegisterExtension(ICapOptionsExtension extension)
{
Extension = extension ?? throw new ArgumentNullException(nameof(extension));
if (extension == null)
throw new ArgumentNullException(nameof(extension));
Extensions.Add(extension);
}
}
}
\ No newline at end of file
......@@ -53,10 +53,13 @@ namespace Microsoft.Extensions.DependencyInjection
services.AddSingleton<IQueueExecutorFactory, QueueExecutorFactory>();
services.AddSingleton<IQueueExecutor, SubscibeQueueExecutor>();
//Options
//Options and extension service
var options = new CapOptions();
setupAction(options);
options.Extension?.AddServices(services);
foreach (var serviceExtension in options.Extensions)
{
serviceExtension.AddServices(services);
}
services.AddSingleton(options);
return new CapBuilder(services);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment