Преглед на файлове

modify CapOptions Extension to support multiple extensions.

master
yangxiaodong преди 7 години
родител
ревизия
9de285b5dd
променени са 2 файла, в които са добавени 12 реда и са изтрити 4 реда
  1. +7
    -2
      src/DotNetCore.CAP/CAP.Options.cs
  2. +5
    -2
      src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs

+ 7
- 2
src/DotNetCore.CAP/CAP.Options.cs Целия файл

@@ -1,4 +1,5 @@
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);
}
}
}

+ 5
- 2
src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs Целия файл

@@ -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);


Зареждане…
Отказ
Запис