Browse Source

Remove autofac from the solution

pull/1900/head
Alex Driver 2 years ago
parent
commit
89c2291812
38 changed files with 94 additions and 227 deletions
  1. +2
    -1
      src/BuildingBlocks/EventBus/EventBus/EventBus.csproj
  2. +23
    -0
      src/BuildingBlocks/EventBus/EventBus/EventBusServiceCollectionExtensions.cs
  3. +6
    -8
      src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs
  4. +0
    -1
      src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj
  5. +1
    -1
      src/BuildingBlocks/EventBus/EventBusRabbitMQ/GlobalUsings.cs
  6. +6
    -7
      src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.cs
  7. +0
    -1
      src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj
  8. +1
    -1
      src/BuildingBlocks/EventBus/EventBusServiceBus/GlobalUsings.cs
  9. +0
    -1
      src/Services/Basket/Basket.API/Basket.API.csproj
  10. +0
    -2
      src/Services/Basket/Basket.API/GlobalUsings.cs
  11. +5
    -10
      src/Services/Basket/Basket.API/Startup.cs
  12. +3
    -3
      src/Services/Basket/Basket.FunctionalTests/Base/BasketTestStartup.cs
  13. +0
    -2
      src/Services/Catalog/Catalog.API/GlobalUsings.cs
  14. +5
    -10
      src/Services/Catalog/Catalog.API/Startup.cs
  15. +0
    -2
      src/Services/Identity/Identity.API/GlobalUsings.cs
  16. +0
    -1
      src/Services/Identity/Identity.API/Identity.API.csproj
  17. +1
    -6
      src/Services/Identity/Identity.API/Startup.cs
  18. +0
    -3
      src/Services/Ordering/Ordering.API/GlobalUsings.cs
  19. +0
    -38
      src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/ApplicationModule.cs
  20. +0
    -36
      src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs
  21. +0
    -1
      src/Services/Ordering/Ordering.API/Ordering.API.csproj
  22. +12
    -15
      src/Services/Ordering/Ordering.API/Startup.cs
  23. +5
    -6
      src/Services/Ordering/Ordering.BackgroundTasks/Extensions/CustomExtensionMethods.cs
  24. +0
    -2
      src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj
  25. +0
    -2
      src/Services/Ordering/Ordering.BackgroundTasks/Program.cs
  26. +2
    -2
      src/Services/Ordering/Ordering.FunctionalTests/OrderingTestStartup.cs
  27. +0
    -20
      src/Services/Ordering/Ordering.SignalrHub/AutofacModules/ApplicationModule.cs
  28. +1
    -4
      src/Services/Ordering/Ordering.SignalrHub/GlobalUsings.cs
  29. +0
    -1
      src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj
  30. +6
    -11
      src/Services/Ordering/Ordering.SignalrHub/Startup.cs
  31. +1
    -3
      src/Services/Payment/Payment.API/GlobalUsings.cs
  32. +1
    -2
      src/Services/Payment/Payment.API/Payment.API.csproj
  33. +5
    -9
      src/Services/Payment/Payment.API/Startup.cs
  34. +1
    -3
      src/Services/Webhooks/Webhooks.API/GlobalUsings.cs
  35. +5
    -9
      src/Services/Webhooks/Webhooks.API/Startup.cs
  36. +0
    -1
      src/Services/Webhooks/Webhooks.API/Webhooks.API.csproj
  37. +1
    -1
      src/Web/WebMVC/Services/OrderingService.cs
  38. +1
    -1
      src/docker-compose.override.yml

+ 2
- 1
src/BuildingBlocks/EventBus/EventBus/EventBus.csproj View File

@ -5,7 +5,8 @@
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.EventBus</RootNamespace> <RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.EventBus</RootNamespace>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

+ 23
- 0
src/BuildingBlocks/EventBus/EventBus/EventBusServiceCollectionExtensions.cs View File

@ -0,0 +1,23 @@
using Microsoft.Extensions.DependencyInjection;
using System.Reflection;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
{
public static class EventBusServiceCollectionExtensions
{
public static IServiceCollection AddEventHandlers(this IServiceCollection services, System.Reflection.Assembly assembly)
{
foreach (var typeInfo in assembly.GetTypes()
.Where(t => typeof(IIntegrationEventHandler).IsAssignableFrom(t)
&& t.IsClass
&& !t.IsAbstract
&& !t.ContainsGenericParameters
&& t.GetConstructors(BindingFlags.Public | BindingFlags.Instance)?.Length != 0))
{
services.AddScoped(typeInfo);
}
return services;
}
}
}

+ 6
- 8
src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs View File

@ -3,26 +3,24 @@
public class EventBusRabbitMQ : IEventBus, IDisposable public class EventBusRabbitMQ : IEventBus, IDisposable
{ {
const string BROKER_NAME = "eshop_event_bus"; const string BROKER_NAME = "eshop_event_bus";
const string AUTOFAC_SCOPE_NAME = "eshop_event_bus";
private readonly IRabbitMQPersistentConnection _persistentConnection; private readonly IRabbitMQPersistentConnection _persistentConnection;
private readonly ILogger<EventBusRabbitMQ> _logger; private readonly ILogger<EventBusRabbitMQ> _logger;
private readonly IEventBusSubscriptionsManager _subsManager; private readonly IEventBusSubscriptionsManager _subsManager;
private readonly ILifetimeScope _autofac;
private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly int _retryCount; private readonly int _retryCount;
private IModel _consumerChannel; private IModel _consumerChannel;
private string _queueName; private string _queueName;
public EventBusRabbitMQ(IRabbitMQPersistentConnection persistentConnection, ILogger<EventBusRabbitMQ> logger, public EventBusRabbitMQ(IRabbitMQPersistentConnection persistentConnection, ILogger<EventBusRabbitMQ> logger,
ILifetimeScope autofac, IEventBusSubscriptionsManager subsManager, string queueName = null, int retryCount = 5)
IServiceScopeFactory serviceScopeFactory, IEventBusSubscriptionsManager subsManager, string queueName = null, int retryCount = 5)
{ {
_persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection)); _persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection));
_logger = logger ?? throw new ArgumentNullException(nameof(logger)); _logger = logger ?? throw new ArgumentNullException(nameof(logger));
_subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager(); _subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager();
_queueName = queueName; _queueName = queueName;
_consumerChannel = CreateConsumerChannel(); _consumerChannel = CreateConsumerChannel();
_autofac = autofac;
_serviceScopeFactory = serviceScopeFactory;
_retryCount = retryCount; _retryCount = retryCount;
_subsManager.OnEventRemoved += SubsManager_OnEventRemoved; _subsManager.OnEventRemoved += SubsManager_OnEventRemoved;
} }
@ -244,14 +242,14 @@ public class EventBusRabbitMQ : IEventBus, IDisposable
if (_subsManager.HasSubscriptionsForEvent(eventName)) if (_subsManager.HasSubscriptionsForEvent(eventName))
{ {
using (var scope = _autofac.BeginLifetimeScope(AUTOFAC_SCOPE_NAME))
using (var scope = _serviceScopeFactory.CreateScope())
{ {
var subscriptions = _subsManager.GetHandlersForEvent(eventName); var subscriptions = _subsManager.GetHandlersForEvent(eventName);
foreach (var subscription in subscriptions) foreach (var subscription in subscriptions)
{ {
if (subscription.IsDynamic) if (subscription.IsDynamic)
{ {
var handler = scope.ResolveOptional(subscription.HandlerType) as IDynamicIntegrationEventHandler;
var handler = scope.ServiceProvider.GetService(subscription.HandlerType) as IDynamicIntegrationEventHandler;
if (handler == null) continue; if (handler == null) continue;
using dynamic eventData = JsonDocument.Parse(message); using dynamic eventData = JsonDocument.Parse(message);
await Task.Yield(); await Task.Yield();
@ -259,7 +257,7 @@ public class EventBusRabbitMQ : IEventBus, IDisposable
} }
else else
{ {
var handler = scope.ResolveOptional(subscription.HandlerType);
var handler = scope.ServiceProvider.GetService(subscription.HandlerType);
if (handler == null) continue; if (handler == null) continue;
var eventType = _subsManager.GetEventTypeByName(eventName); var eventType = _subsManager.GetEventTypeByName(eventName);
var integrationEvent = JsonSerializer.Deserialize(message, eventType, new JsonSerializerOptions() { PropertyNameCaseInsensitive= true}); var integrationEvent = JsonSerializer.Deserialize(message, eventType, new JsonSerializerOptions() { PropertyNameCaseInsensitive= true});


+ 0
- 1
src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj View File

@ -6,7 +6,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Autofac" Version="6.1.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /> <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Polly" Version="7.2.1" /> <PackageReference Include="Polly" Version="7.2.1" />


+ 1
- 1
src/BuildingBlocks/EventBus/EventBusRabbitMQ/GlobalUsings.cs View File

@ -7,7 +7,7 @@ global using RabbitMQ.Client.Exceptions;
global using System; global using System;
global using System.IO; global using System.IO;
global using System.Net.Sockets; global using System.Net.Sockets;
global using Autofac;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;


+ 6
- 7
src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.cs View File

@ -5,21 +5,20 @@ public class EventBusServiceBus : IEventBus, IDisposable
private readonly IServiceBusPersisterConnection _serviceBusPersisterConnection; private readonly IServiceBusPersisterConnection _serviceBusPersisterConnection;
private readonly ILogger<EventBusServiceBus> _logger; private readonly ILogger<EventBusServiceBus> _logger;
private readonly IEventBusSubscriptionsManager _subsManager; private readonly IEventBusSubscriptionsManager _subsManager;
private readonly ILifetimeScope _autofac;
private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly string _topicName = "eshop_event_bus"; private readonly string _topicName = "eshop_event_bus";
private readonly string _subscriptionName; private readonly string _subscriptionName;
private ServiceBusSender _sender; private ServiceBusSender _sender;
private ServiceBusProcessor _processor; private ServiceBusProcessor _processor;
private readonly string AUTOFAC_SCOPE_NAME = "eshop_event_bus";
private const string INTEGRATION_EVENT_SUFFIX = "IntegrationEvent"; private const string INTEGRATION_EVENT_SUFFIX = "IntegrationEvent";
public EventBusServiceBus(IServiceBusPersisterConnection serviceBusPersisterConnection, public EventBusServiceBus(IServiceBusPersisterConnection serviceBusPersisterConnection,
ILogger<EventBusServiceBus> logger, IEventBusSubscriptionsManager subsManager, ILifetimeScope autofac, string subscriptionClientName)
ILogger<EventBusServiceBus> logger, IEventBusSubscriptionsManager subsManager, IServiceScopeFactory serviceScopeFactory, string subscriptionClientName)
{ {
_serviceBusPersisterConnection = serviceBusPersisterConnection; _serviceBusPersisterConnection = serviceBusPersisterConnection;
_logger = logger ?? throw new ArgumentNullException(nameof(logger)); _logger = logger ?? throw new ArgumentNullException(nameof(logger));
_subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager(); _subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager();
_autofac = autofac;
_serviceScopeFactory = serviceScopeFactory;
_subscriptionName = subscriptionClientName; _subscriptionName = subscriptionClientName;
_sender = _serviceBusPersisterConnection.TopicClient.CreateSender(_topicName); _sender = _serviceBusPersisterConnection.TopicClient.CreateSender(_topicName);
ServiceBusProcessorOptions options = new ServiceBusProcessorOptions { MaxConcurrentCalls = 10, AutoCompleteMessages = false }; ServiceBusProcessorOptions options = new ServiceBusProcessorOptions { MaxConcurrentCalls = 10, AutoCompleteMessages = false };
@ -155,14 +154,14 @@ public class EventBusServiceBus : IEventBus, IDisposable
var processed = false; var processed = false;
if (_subsManager.HasSubscriptionsForEvent(eventName)) if (_subsManager.HasSubscriptionsForEvent(eventName))
{ {
using (var scope = _autofac.BeginLifetimeScope(AUTOFAC_SCOPE_NAME))
using (var scope = _serviceScopeFactory.CreateScope())
{ {
var subscriptions = _subsManager.GetHandlersForEvent(eventName); var subscriptions = _subsManager.GetHandlersForEvent(eventName);
foreach (var subscription in subscriptions) foreach (var subscription in subscriptions)
{ {
if (subscription.IsDynamic) if (subscription.IsDynamic)
{ {
var handler = scope.ResolveOptional(subscription.HandlerType) as IDynamicIntegrationEventHandler;
var handler = scope.ServiceProvider.GetService(subscription.HandlerType) as IDynamicIntegrationEventHandler;
if (handler == null) continue; if (handler == null) continue;
using dynamic eventData = JsonDocument.Parse(message); using dynamic eventData = JsonDocument.Parse(message);
@ -170,7 +169,7 @@ public class EventBusServiceBus : IEventBus, IDisposable
} }
else else
{ {
var handler = scope.ResolveOptional(subscription.HandlerType);
var handler = scope.ServiceProvider.GetService(subscription.HandlerType);
if (handler == null) continue; if (handler == null) continue;
var eventType = _subsManager.GetEventTypeByName(eventName); var eventType = _subsManager.GetEventTypeByName(eventName);
var integrationEvent = JsonSerializer.Deserialize(message, eventType); var integrationEvent = JsonSerializer.Deserialize(message, eventType);


+ 0
- 1
src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj View File

@ -6,7 +6,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Autofac" Version="6.1.0" />
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.2.1" /> <PackageReference Include="Azure.Messaging.ServiceBus" Version="7.2.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /> <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />


+ 1
- 1
src/BuildingBlocks/EventBus/EventBusServiceBus/GlobalUsings.cs View File

@ -6,7 +6,7 @@ global using System.Linq;
global using System.Text.Json.Serialization; global using System.Text.Json.Serialization;
global using System.Threading.Tasks; global using System.Threading.Tasks;
global using System; global using System;
global using Autofac;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
global using Microsoft.Extensions.Logging; global using Microsoft.Extensions.Logging;
global using System.Text; global using System.Text;


+ 0
- 1
src/Services/Basket/Basket.API/Basket.API.csproj View File

@ -20,7 +20,6 @@
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="5.0.2" /> <PackageReference Include="AspNetCore.HealthChecks.Redis" Version="5.0.2" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0-preview.1" />
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.1" /> <PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.1" />
<PackageReference Include="Azure.Identity" Version="1.4.0" /> <PackageReference Include="Azure.Identity" Version="1.4.0" />
<PackageReference Include="Google.Protobuf" Version="3.15.0" /> <PackageReference Include="Google.Protobuf" Version="3.15.0" />


+ 0
- 2
src/Services/Basket/Basket.API/GlobalUsings.cs View File

@ -1,5 +1,3 @@
global using Autofac.Extensions.DependencyInjection;
global using Autofac;
global using Azure.Core; global using Azure.Core;
global using Azure.Identity; global using Azure.Identity;
global using Basket.API.Infrastructure.ActionResults; global using Basket.API.Infrastructure.ActionResults;


+ 5
- 10
src/Services/Basket/Basket.API/Startup.cs View File

@ -9,7 +9,7 @@ public class Startup
public IConfiguration Configuration { get; } public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public virtual IServiceProvider ConfigureServices(IServiceCollection services)
public virtual void ConfigureServices(IServiceCollection services)
{ {
services.AddGrpc(options => services.AddGrpc(options =>
{ {
@ -135,11 +135,6 @@ public class Startup
services.AddTransient<IIdentityService, IdentityService>(); services.AddTransient<IIdentityService, IdentityService>();
services.AddOptions(); services.AddOptions();
var container = new ContainerBuilder();
container.Populate(services);
return new AutofacServiceProvider(container.Build());
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -240,13 +235,13 @@ public class Startup
services.AddSingleton<IEventBus, EventBusServiceBus>(sp => services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
{ {
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>(); var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>(); var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
string subscriptionName = Configuration["SubscriptionClientName"]; string subscriptionName = Configuration["SubscriptionClientName"];
return new EventBusServiceBus(serviceBusPersisterConnection, logger, return new EventBusServiceBus(serviceBusPersisterConnection, logger,
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
}); });
} }
else else
@ -255,7 +250,7 @@ public class Startup
{ {
var subscriptionClientName = Configuration["SubscriptionClientName"]; var subscriptionClientName = Configuration["SubscriptionClientName"];
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>(); var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>(); var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
@ -265,7 +260,7 @@ public class Startup
retryCount = int.Parse(Configuration["EventBusRetryCount"]); retryCount = int.Parse(Configuration["EventBusRetryCount"]);
} }
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
}); });
} }


+ 3
- 3
src/Services/Basket/Basket.FunctionalTests/Base/BasketTestStartup.cs View File

@ -8,14 +8,14 @@ namespace Basket.FunctionalTests.Base
{ {
} }
public override IServiceProvider ConfigureServices(IServiceCollection services)
public override void ConfigureServices(IServiceCollection services)
{ {
// Added to avoid the Authorize data annotation in test environment. // Added to avoid the Authorize data annotation in test environment.
// Property "SuppressCheckForUnhandledSecurityMetadata" in appsettings.json // Property "SuppressCheckForUnhandledSecurityMetadata" in appsettings.json
services.Configure<RouteOptions>(Configuration); services.Configure<RouteOptions>(Configuration);
return base.ConfigureServices(services);
base.ConfigureServices(services);
} }
protected override void ConfigureAuth(IApplicationBuilder app) protected override void ConfigureAuth(IApplicationBuilder app)
{ {
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant()) if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())


+ 0
- 2
src/Services/Catalog/Catalog.API/GlobalUsings.cs View File

@ -1,7 +1,5 @@
global using Azure.Core; global using Azure.Core;
global using Azure.Identity; global using Azure.Identity;
global using Autofac.Extensions.DependencyInjection;
global using Autofac;
global using Microsoft.eShopOnContainers.Services.Catalog.API.Extensions; global using Microsoft.eShopOnContainers.Services.Catalog.API.Extensions;
global using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.ActionResults; global using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.ActionResults;
global using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.Exceptions; global using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.Exceptions;


+ 5
- 10
src/Services/Catalog/Catalog.API/Startup.cs View File

@ -9,7 +9,7 @@ public class Startup
public IConfiguration Configuration { get; } public IConfiguration Configuration { get; }
public IServiceProvider ConfigureServices(IServiceCollection services)
public void ConfigureServices(IServiceCollection services)
{ {
services.AddAppInsight(Configuration) services.AddAppInsight(Configuration)
.AddGrpc().Services .AddGrpc().Services
@ -20,11 +20,6 @@ public class Startup
.AddEventBus(Configuration) .AddEventBus(Configuration)
.AddSwagger(Configuration) .AddSwagger(Configuration)
.AddCustomHealthCheck(Configuration); .AddCustomHealthCheck(Configuration);
var container = new ContainerBuilder();
container.Populate(services);
return new AutofacServiceProvider(container.Build());
} }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
@ -294,13 +289,13 @@ public static class CustomExtensionMethods
services.AddSingleton<IEventBus, EventBusServiceBus>(sp => services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
{ {
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>(); var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>(); var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
string subscriptionName = configuration["SubscriptionClientName"]; string subscriptionName = configuration["SubscriptionClientName"];
return new EventBusServiceBus(serviceBusPersisterConnection, logger, return new EventBusServiceBus(serviceBusPersisterConnection, logger,
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
}); });
} }
@ -310,7 +305,7 @@ public static class CustomExtensionMethods
{ {
var subscriptionClientName = configuration["SubscriptionClientName"]; var subscriptionClientName = configuration["SubscriptionClientName"];
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>(); var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>(); var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
@ -320,7 +315,7 @@ public static class CustomExtensionMethods
retryCount = int.Parse(configuration["EventBusRetryCount"]); retryCount = int.Parse(configuration["EventBusRetryCount"]);
} }
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
}); });
} }


+ 0
- 2
src/Services/Identity/Identity.API/GlobalUsings.cs View File

@ -1,7 +1,5 @@
global using Microsoft.eShopOnContainers.Services.Identity.API.Extensions; global using Microsoft.eShopOnContainers.Services.Identity.API.Extensions;
global using System.IO.Compression; global using System.IO.Compression;
global using Autofac.Extensions.DependencyInjection;
global using Autofac;
global using Azure.Core; global using Azure.Core;
global using Azure.Identity; global using Azure.Identity;
global using HealthChecks.UI.Client; global using HealthChecks.UI.Client;


+ 0
- 1
src/Services/Identity/Identity.API/Identity.API.csproj View File

@ -17,7 +17,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.3" /> <PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.3" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0-preview.1" />
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="3.1.4" /> <PackageReference Include="IdentityServer4.AspNetIdentity" Version="3.1.4" />
<PackageReference Include="IdentityServer4.EntityFramework.Storage" Version="3.1.4" /> <PackageReference Include="IdentityServer4.EntityFramework.Storage" Version="3.1.4" />
<PackageReference Include="IdentityServer4.EntityFramework" Version="3.1.4" /> <PackageReference Include="IdentityServer4.EntityFramework" Version="3.1.4" />


+ 1
- 6
src/Services/Identity/Identity.API/Startup.cs View File

@ -12,7 +12,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
public IConfiguration Configuration { get; } public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public IServiceProvider ConfigureServices(IServiceCollection services)
public void ConfigureServices(IServiceCollection services)
{ {
RegisterAppInsights(services); RegisterAppInsights(services);
@ -88,11 +88,6 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
services.AddControllers(); services.AddControllers();
services.AddControllersWithViews(); services.AddControllersWithViews();
services.AddRazorPages(); services.AddRazorPages();
var container = new ContainerBuilder();
container.Populate(services);
return new AutofacServiceProvider(container.Build());
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.


+ 0
- 3
src/Services/Ordering/Ordering.API/GlobalUsings.cs View File

@ -1,7 +1,5 @@
global using ApiModels = Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models; global using ApiModels = Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models;
global using AppCommand = Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands; global using AppCommand = Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands;
global using Autofac.Extensions.DependencyInjection;
global using Autofac;
global using Azure.Core; global using Azure.Core;
global using Azure.Identity; global using Azure.Identity;
global using Dapper; global using Dapper;
@ -36,7 +34,6 @@ global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Comma
global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderStartedEvent; global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderStartedEvent;
global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderStockConfirmed; global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderStockConfirmed;
global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents.EventHandling; global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents.EventHandling;
global using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules;
global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents.Events; global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents.Events;
global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents; global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents;
global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models; global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models;


+ 0
- 38
src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/ApplicationModule.cs View File

@ -1,38 +0,0 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules;
public class ApplicationModule
: Autofac.Module
{
public string QueriesConnectionString { get; }
public ApplicationModule(string qconstr)
{
QueriesConnectionString = qconstr;
}
protected override void Load(ContainerBuilder builder)
{
builder.Register(c => new OrderQueries(QueriesConnectionString))
.As<IOrderQueries>()
.InstancePerLifetimeScope();
builder.RegisterType<BuyerRepository>()
.As<IBuyerRepository>()
.InstancePerLifetimeScope();
builder.RegisterType<OrderRepository>()
.As<IOrderRepository>()
.InstancePerLifetimeScope();
builder.RegisterType<RequestManager>()
.As<IRequestManager>()
.InstancePerLifetimeScope();
builder.RegisterAssemblyTypes(typeof(CreateOrderCommandHandler).GetTypeInfo().Assembly)
.AsClosedTypesOf(typeof(IIntegrationEventHandler<>));
}
}

+ 0
- 36
src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs View File

@ -1,36 +0,0 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules;
public class MediatorModule : Autofac.Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterAssemblyTypes(typeof(IMediator).GetTypeInfo().Assembly)
.AsImplementedInterfaces();
// Register all the Command classes (they implement IRequestHandler) in assembly holding the Commands
builder.RegisterAssemblyTypes(typeof(CreateOrderCommand).GetTypeInfo().Assembly)
.AsClosedTypesOf(typeof(IRequestHandler<,>));
// Register the DomainEventHandler classes (they implement INotificationHandler<>) in assembly holding the Domain Events
builder.RegisterAssemblyTypes(typeof(ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler).GetTypeInfo().Assembly)
.AsClosedTypesOf(typeof(INotificationHandler<>));
// Register the Command's Validators (Validators based on FluentValidation library)
builder
.RegisterAssemblyTypes(typeof(CreateOrderCommandValidator).GetTypeInfo().Assembly)
.Where(t => t.IsClosedTypeOf(typeof(IValidator<>)))
.AsImplementedInterfaces();
builder.Register<ServiceFactory>(context =>
{
var componentContext = context.Resolve<IComponentContext>();
return t => { object o; return componentContext.TryResolve(t, out o) ? o : null; };
});
builder.RegisterGeneric(typeof(LoggingBehavior<,>)).As(typeof(IPipelineBehavior<,>));
builder.RegisterGeneric(typeof(ValidatorBehavior<,>)).As(typeof(IPipelineBehavior<,>));
builder.RegisterGeneric(typeof(TransactionBehaviour<,>)).As(typeof(IPipelineBehavior<,>));
}
}

+ 0
- 1
src/Services/Ordering/Ordering.API/Ordering.API.csproj View File

@ -40,7 +40,6 @@
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.3" /> <PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.3" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.1" /> <PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.1" />
<PackageReference Include="Azure.Identity" Version="1.4.0" /> <PackageReference Include="Azure.Identity" Version="1.4.0" />
<PackageReference Include="Dapper" Version="2.0.78" /> <PackageReference Include="Dapper" Version="2.0.78" />


+ 12
- 15
src/Services/Ordering/Ordering.API/Startup.cs View File

@ -9,7 +9,7 @@ public class Startup
public IConfiguration Configuration { get; } public IConfiguration Configuration { get; }
public virtual IServiceProvider ConfigureServices(IServiceCollection services)
public virtual void ConfigureServices(IServiceCollection services)
{ {
services services
.AddGrpc(options => .AddGrpc(options =>
@ -25,16 +25,13 @@ public class Startup
.AddCustomIntegrations(Configuration) .AddCustomIntegrations(Configuration)
.AddCustomConfiguration(Configuration) .AddCustomConfiguration(Configuration)
.AddEventBus(Configuration) .AddEventBus(Configuration)
.AddCustomAuthentication(Configuration);
//configure autofac
var container = new ContainerBuilder();
container.Populate(services);
container.RegisterModule(new MediatorModule());
container.RegisterModule(new ApplicationModule(Configuration["ConnectionString"]));
return new AutofacServiceProvider(container.Build());
.AddCustomAuthentication(Configuration)
.AddScoped<IOrderQueries>(sp => new OrderQueries(Configuration["ConnectionString"]))
.AddScoped<IBuyerRepository, BuyerRepository>()
.AddScoped<IOrderRepository, OrderRepository>()
.AddScoped<IRequestManager, RequestManager>()
.AddEventHandlers(typeof(CreateOrderCommandHandler).GetTypeInfo().Assembly)
.AddMediatR(Assembly.GetExecutingAssembly());
} }
@ -332,13 +329,13 @@ static class CustomExtensionsMethods
services.AddSingleton<IEventBus, EventBusServiceBus>(sp => services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
{ {
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>(); var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>(); var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
string subscriptionName = configuration["SubscriptionClientName"]; string subscriptionName = configuration["SubscriptionClientName"];
return new EventBusServiceBus(serviceBusPersisterConnection, logger, return new EventBusServiceBus(serviceBusPersisterConnection, logger,
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
}); });
} }
else else
@ -347,7 +344,7 @@ static class CustomExtensionsMethods
{ {
var subscriptionClientName = configuration["SubscriptionClientName"]; var subscriptionClientName = configuration["SubscriptionClientName"];
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>(); var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>(); var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
@ -357,7 +354,7 @@ static class CustomExtensionsMethods
retryCount = int.Parse(configuration["EventBusRetryCount"]); retryCount = int.Parse(configuration["EventBusRetryCount"]);
} }
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
}); });
} }


+ 5
- 6
src/Services/Ordering/Ordering.BackgroundTasks/Extensions/CustomExtensionMethods.cs View File

@ -1,5 +1,4 @@
using Autofac;
using Azure.Messaging.ServiceBus;
using Azure.Messaging.ServiceBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ; using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
@ -61,12 +60,12 @@ namespace Ordering.BackgroundTasks.Extensions
services.AddSingleton<IEventBus, EventBusServiceBus>(sp => services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
{ {
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>(); var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>(); var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
string subscriptionName = configuration["SubscriptionClientName"]; string subscriptionName = configuration["SubscriptionClientName"];
return new EventBusServiceBus(serviceBusPersisterConnection, logger, eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
return new EventBusServiceBus(serviceBusPersisterConnection, logger, eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
}); });
} }
else else
@ -104,7 +103,7 @@ namespace Ordering.BackgroundTasks.Extensions
services.AddSingleton<IEventBus, EventBusRabbitMQ>(sp => services.AddSingleton<IEventBus, EventBusRabbitMQ>(sp =>
{ {
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>(); var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>(); var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
@ -115,7 +114,7 @@ namespace Ordering.BackgroundTasks.Extensions
retryCount = int.Parse(configuration["EventBusRetryCount"]); retryCount = int.Parse(configuration["EventBusRetryCount"]);
} }
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
}); });
} }


+ 0
- 2
src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj View File

@ -12,8 +12,6 @@
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Autofac" Version="6.1.0" />
<PackageReference Include="Dapper" Version="2.0.78" /> <PackageReference Include="Dapper" Version="2.0.78" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />


+ 0
- 2
src/Services/Ordering/Ordering.BackgroundTasks/Program.cs View File

@ -1,4 +1,3 @@
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
@ -19,7 +18,6 @@ namespace Ordering.BackgroundTasks
public static IHost CreateHostBuilder(string[] args) => public static IHost CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args) Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>()) .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>())
.ConfigureAppConfiguration((host, builder) => .ConfigureAppConfiguration((host, builder) =>
{ {


+ 2
- 2
src/Services/Ordering/Ordering.FunctionalTests/OrderingTestStartup.cs View File

@ -6,12 +6,12 @@ public class OrderingTestsStartup : Startup
{ {
} }
public override IServiceProvider ConfigureServices(IServiceCollection services)
public override void ConfigureServices(IServiceCollection services)
{ {
// Added to avoid the Authorize data annotation in test environment. // Added to avoid the Authorize data annotation in test environment.
// Property "SuppressCheckForUnhandledSecurityMetadata" in appsettings.json // Property "SuppressCheckForUnhandledSecurityMetadata" in appsettings.json
services.Configure<RouteOptions>(Configuration); services.Configure<RouteOptions>(Configuration);
return base.ConfigureServices(services);
base.ConfigureServices(services);
} }
protected override void ConfigureAuth(IApplicationBuilder app) protected override void ConfigureAuth(IApplicationBuilder app)
{ {


+ 0
- 20
src/Services/Ordering/Ordering.SignalrHub/AutofacModules/ApplicationModule.cs View File

@ -1,20 +0,0 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.AutofacModules;
public class ApplicationModule
: Autofac.Module
{
public string QueriesConnectionString { get; }
public ApplicationModule()
{
}
protected override void Load(ContainerBuilder builder)
{
builder.RegisterAssemblyTypes(typeof(OrderStatusChangedToAwaitingValidationIntegrationEvent).GetTypeInfo().Assembly)
.AsClosedTypesOf(typeof(IIntegrationEventHandler<>));
}
}

+ 1
- 4
src/Services/Ordering/Ordering.SignalrHub/GlobalUsings.cs View File

@ -1,6 +1,4 @@
global using Autofac.Extensions.DependencyInjection;
global using Autofac;
global using HealthChecks.UI.Client;
global using HealthChecks.UI.Client;
global using Microsoft.AspNetCore.Authentication.JwtBearer; global using Microsoft.AspNetCore.Authentication.JwtBearer;
global using Microsoft.AspNetCore.Authorization; global using Microsoft.AspNetCore.Authorization;
global using Microsoft.AspNetCore.Builder; global using Microsoft.AspNetCore.Builder;
@ -20,7 +18,6 @@ global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection; global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Diagnostics.HealthChecks; global using Microsoft.Extensions.Diagnostics.HealthChecks;
global using Microsoft.Extensions.Logging; global using Microsoft.Extensions.Logging;
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.AutofacModules;
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling;
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.Events; global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.Events;
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents; global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents;


+ 0
- 1
src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj View File

@ -15,7 +15,6 @@
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.1.1" /> <PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.1.1" />
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0-preview.1" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.18.0" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.18.0" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.18.0" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.18.0" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="2.0.2-beta2" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="2.0.2-beta2" />


+ 6
- 11
src/Services/Ordering/Ordering.SignalrHub/Startup.cs View File

@ -11,7 +11,7 @@ public class Startup
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public IServiceProvider ConfigureServices(IServiceCollection services)
public void ConfigureServices(IServiceCollection services)
{ {
services services
.AddCustomHealthCheck(Configuration) .AddCustomHealthCheck(Configuration)
@ -86,12 +86,7 @@ public class Startup
services.AddOptions(); services.AddOptions();
//configure autofac
var container = new ContainerBuilder();
container.RegisterModule(new ApplicationModule());
container.Populate(services);
return new AutofacServiceProvider(container.Build());
services.AddEventHandlers(typeof(OrderStatusChangedToAwaitingValidationIntegrationEvent).GetTypeInfo().Assembly);
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -185,13 +180,13 @@ public class Startup
services.AddSingleton<IEventBus, EventBusServiceBus>(sp => services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
{ {
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>(); var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>(); var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
string subscriptionName = Configuration["SubscriptionClientName"]; string subscriptionName = Configuration["SubscriptionClientName"];
return new EventBusServiceBus(serviceBusPersisterConnection, logger, return new EventBusServiceBus(serviceBusPersisterConnection, logger,
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
}); });
} }
else else
@ -200,7 +195,7 @@ public class Startup
{ {
var subscriptionClientName = Configuration["SubscriptionClientName"]; var subscriptionClientName = Configuration["SubscriptionClientName"];
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>(); var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>(); var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
@ -210,7 +205,7 @@ public class Startup
retryCount = int.Parse(Configuration["EventBusRetryCount"]); retryCount = int.Parse(Configuration["EventBusRetryCount"]);
} }
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
}); });
} }


+ 1
- 3
src/Services/Payment/Payment.API/GlobalUsings.cs View File

@ -1,6 +1,4 @@
global using Autofac.Extensions.DependencyInjection;
global using Autofac;
global using Azure.Core;
global using Azure.Core;
global using Azure.Identity; global using Azure.Identity;
global using HealthChecks.UI.Client; global using HealthChecks.UI.Client;
global using Microsoft.AspNetCore.Diagnostics.HealthChecks; global using Microsoft.AspNetCore.Diagnostics.HealthChecks;


+ 1
- 2
src/Services/Payment/Payment.API/Payment.API.csproj View File

@ -12,8 +12,7 @@
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.1" />
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.2" />
<PackageReference Include="Azure.Identity" Version="1.4.0" /> <PackageReference Include="Azure.Identity" Version="1.4.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />


+ 5
- 9
src/Services/Payment/Payment.API/Startup.cs View File

@ -10,7 +10,7 @@ public class Startup
public IConfiguration Configuration { get; } public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public IServiceProvider ConfigureServices(IServiceCollection services)
public void ConfigureServices(IServiceCollection services)
{ {
services.AddCustomHealthCheck(Configuration); services.AddCustomHealthCheck(Configuration);
services.Configure<PaymentSettings>(Configuration); services.Configure<PaymentSettings>(Configuration);
@ -59,10 +59,6 @@ public class Startup
} }
RegisterEventBus(services); RegisterEventBus(services);
var container = new ContainerBuilder();
container.Populate(services);
return new AutofacServiceProvider(container.Build());
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -107,13 +103,13 @@ public class Startup
services.AddSingleton<IEventBus, EventBusServiceBus>(sp => services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
{ {
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>(); var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>(); var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
string subscriptionName = Configuration["SubscriptionClientName"]; string subscriptionName = Configuration["SubscriptionClientName"];
return new EventBusServiceBus(serviceBusPersisterConnection, logger, return new EventBusServiceBus(serviceBusPersisterConnection, logger,
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
}); });
} }
else else
@ -122,7 +118,7 @@ public class Startup
{ {
var subscriptionClientName = Configuration["SubscriptionClientName"]; var subscriptionClientName = Configuration["SubscriptionClientName"];
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>(); var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>(); var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
@ -132,7 +128,7 @@ public class Startup
retryCount = int.Parse(Configuration["EventBusRetryCount"]); retryCount = int.Parse(Configuration["EventBusRetryCount"]);
} }
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
}); });
} }


+ 1
- 3
src/Services/Webhooks/Webhooks.API/GlobalUsings.cs View File

@ -1,6 +1,4 @@
global using Autofac.Extensions.DependencyInjection;
global using Autofac;
global using Devspaces.Support;
global using Devspaces.Support;
global using HealthChecks.UI.Client; global using HealthChecks.UI.Client;
global using Microsoft.AspNetCore.Authentication.JwtBearer; global using Microsoft.AspNetCore.Authentication.JwtBearer;
global using Microsoft.AspNetCore.Authorization; global using Microsoft.AspNetCore.Authorization;


+ 5
- 9
src/Services/Webhooks/Webhooks.API/Startup.cs View File

@ -9,7 +9,7 @@ public class Startup
} }
public IServiceProvider ConfigureServices(IServiceCollection services)
public void ConfigureServices(IServiceCollection services)
{ {
services services
.AddAppInsight(Configuration) .AddAppInsight(Configuration)
@ -27,10 +27,6 @@ public class Startup
.AddTransient<IGrantUrlTesterService, GrantUrlTesterService>() .AddTransient<IGrantUrlTesterService, GrantUrlTesterService>()
.AddTransient<IWebhooksRetriever, WebhooksRetriever>() .AddTransient<IWebhooksRetriever, WebhooksRetriever>()
.AddTransient<IWebhooksSender, WebhooksSender>(); .AddTransient<IWebhooksSender, WebhooksSender>();
var container = new ContainerBuilder();
container.Populate(services);
return new AutofacServiceProvider(container.Build());
} }
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
@ -175,13 +171,13 @@ static class CustomExtensionMethods
services.AddSingleton<IEventBus, EventBusServiceBus>(sp => services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
{ {
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>(); var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>(); var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
string subscriptionName = configuration["SubscriptionClientName"]; string subscriptionName = configuration["SubscriptionClientName"];
return new EventBusServiceBus(serviceBusPersisterConnection, logger, return new EventBusServiceBus(serviceBusPersisterConnection, logger,
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
}); });
} }
@ -191,7 +187,7 @@ static class CustomExtensionMethods
{ {
var subscriptionClientName = configuration["SubscriptionClientName"]; var subscriptionClientName = configuration["SubscriptionClientName"];
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>(); var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>(); var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
@ -201,7 +197,7 @@ static class CustomExtensionMethods
retryCount = int.Parse(configuration["EventBusRetryCount"]); retryCount = int.Parse(configuration["EventBusRetryCount"]);
} }
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
}); });
} }


+ 0
- 1
src/Services/Webhooks/Webhooks.API/Webhooks.API.csproj View File

@ -12,7 +12,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />


+ 1
- 1
src/Web/WebMVC/Services/OrderingService.cs View File

@ -36,7 +36,7 @@ public class OrderingService : IOrderingService
var uri = API.Order.GetAllMyOrders(_remoteServiceBaseUrl); var uri = API.Order.GetAllMyOrders(_remoteServiceBaseUrl);
var responseString = await _httpClient.GetStringAsync(uri); var responseString = await _httpClient.GetStringAsync(uri);
var response = JsonSerializer.Deserialize<List<Order>>(responseString, new JsonSerializerOptions var response = JsonSerializer.Deserialize<List<Order>>(responseString, new JsonSerializerOptions
{ {
PropertyNameCaseInsensitive = true PropertyNameCaseInsensitive = true


+ 1
- 1
src/docker-compose.override.yml View File

@ -20,7 +20,7 @@ services:
ports: ports:
- "5433:1433" - "5433:1433"
volumes: volumes:
- eshop-sqldata:/var/opt/mssql
- eshop-sqldata:/var/opt/mssql/data
nosqldata: nosqldata:
ports: ports:


Loading…
Cancel
Save