Finish removing Autofac
This commit is contained in:
parent
b9f48faf99
commit
fea08c78bb
@ -4,7 +4,6 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
public class EventBusRabbitMQ : IEventBus, IDisposable
|
||||
{
|
||||
const string BROKER_NAME = "eshop_event_bus";
|
||||
const string AUTOFAC_SCOPE_NAME = "eshop_event_bus";
|
||||
|
||||
private readonly IRabbitMQPersistentConnection _persistentConnection;
|
||||
private readonly ILogger<EventBusRabbitMQ> _logger;
|
||||
|
@ -6,7 +6,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac" />
|
||||
<PackageReference Include="Microsoft.CSharp" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" />
|
||||
<PackageReference Include="Polly" />
|
||||
|
@ -7,7 +7,6 @@ global using RabbitMQ.Client.Exceptions;
|
||||
global using System;
|
||||
global using System.IO;
|
||||
global using System.Net.Sockets;
|
||||
global using Autofac;
|
||||
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||
|
@ -6,7 +6,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac" />
|
||||
<PackageReference Include="Azure.Messaging.ServiceBus" />
|
||||
<PackageReference Include="Microsoft.CSharp" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" />
|
||||
|
@ -2,7 +2,6 @@
|
||||
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||
global using System.Threading.Tasks;
|
||||
global using System;
|
||||
global using Autofac;
|
||||
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||
global using Microsoft.Extensions.Logging;
|
||||
global using System.Text;
|
||||
|
@ -14,8 +14,6 @@
|
||||
<PackageVersion Include="AspNetCore.HealthChecks.UI.Client" Version="6.0.5" />
|
||||
<PackageVersion Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="6.0.5" />
|
||||
<PackageVersion Include="AspNetCore.HealthChecks.Uris" Version="6.0.3" />
|
||||
<PackageVersion Include="Autofac" Version="6.5.0" />
|
||||
<PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageVersion Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.2" />
|
||||
<PackageVersion Include="Azure.Identity" Version="1.8.2" />
|
||||
<PackageVersion Include="Azure.Messaging.ServiceBus" Version="7.12.0" />
|
||||
|
@ -6,7 +6,6 @@ global using System.Net;
|
||||
global using System.Security.Claims;
|
||||
global using System.Text.Json;
|
||||
global using System.Threading.Tasks;
|
||||
global using Autofac;
|
||||
global using Basket.API.Infrastructure.ActionResults;
|
||||
global using Basket.API.Infrastructure.Exceptions;
|
||||
global using Basket.API.Infrastructure.Filters;
|
||||
|
@ -11,7 +11,6 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" />
|
||||
<PackageReference Include="Duende.IdentityServer.AspNetIdentity" />
|
||||
<PackageReference Include="Duende.IdentityServer.EntityFramework.Storage" />
|
||||
<PackageReference Include="Duende.IdentityServer.EntityFramework" />
|
||||
|
@ -1,7 +1,5 @@
|
||||
global using ApiModels = Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models;
|
||||
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.Identity;
|
||||
global using Dapper;
|
||||
|
@ -1,20 +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)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules;
|
||||
|
||||
public class MediatorModule : Autofac.Module
|
||||
{
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="Ordering.FunctionalTests"/>
|
||||
<InternalsVisibleTo Include="Ordering.FunctionalTests" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -44,7 +44,6 @@
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" />
|
||||
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" />
|
||||
<PackageReference Include="Azure.Identity" />
|
||||
<PackageReference Include="Dapper" />
|
||||
@ -74,4 +73,4 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
@ -38,11 +38,6 @@ builder.Services
|
||||
.AddCustomConfiguration(builder.Configuration)
|
||||
.AddEventBus(builder.Configuration);
|
||||
|
||||
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
||||
// Register your own things directly with Autofac here. Don't
|
||||
// call builder.Populate(), that happens in AutofacServiceProviderFactory
|
||||
// for you.
|
||||
|
||||
var services = builder.Services;
|
||||
|
||||
services.AddMediatR(cfg =>
|
||||
|
@ -12,8 +12,6 @@
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" />
|
||||
<PackageReference Include="Autofac" />
|
||||
<PackageReference Include="Dapper" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||
|
@ -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,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.Authorization;
|
||||
global using Microsoft.AspNetCore.Builder;
|
||||
@ -19,7 +17,6 @@ global using Microsoft.Extensions.Configuration;
|
||||
global using Microsoft.Extensions.DependencyInjection;
|
||||
global using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
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;
|
||||
global using RabbitMQ.Client;
|
||||
|
@ -11,7 +11,6 @@
|
||||
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" />
|
||||
|
@ -74,11 +74,16 @@ else
|
||||
return new DefaultRabbitMQPersistentConnection(factory, logger, retryCount);
|
||||
});
|
||||
}
|
||||
|
||||
ConfigureAuthService(builder.Services, builder.Configuration);
|
||||
RegisterEventBus(builder.Services, builder.Configuration);
|
||||
builder.Services.AddOptions();
|
||||
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
||||
builder.Host.ConfigureContainer<ContainerBuilder>(conBuilder => conBuilder.RegisterModule(new ApplicationModule()));
|
||||
builder.Services.AddSingleton<IIntegrationEventHandler<OrderStatusChangedToAwaitingValidationIntegrationEvent>, OrderStatusChangedToAwaitingValidationIntegrationEventHandler>();
|
||||
builder.Services.AddSingleton<IIntegrationEventHandler<OrderStatusChangedToCancelledIntegrationEvent>, OrderStatusChangedToCancelledIntegrationEventHandler>();
|
||||
builder.Services.AddSingleton<IIntegrationEventHandler<OrderStatusChangedToPaidIntegrationEvent>, OrderStatusChangedToPaidIntegrationEventHandler>();
|
||||
builder.Services.AddSingleton<IIntegrationEventHandler<OrderStatusChangedToShippedIntegrationEvent>, OrderStatusChangedToShippedIntegrationEventHandler>();
|
||||
builder.Services.AddSingleton<IIntegrationEventHandler<OrderStatusChangedToStockConfirmedIntegrationEvent>, OrderStatusChangedToStockConfirmedIntegrationEventHandler>();
|
||||
builder.Services.AddSingleton<IIntegrationEventHandler<OrderStatusChangedToSubmittedIntegrationEvent>, OrderStatusChangedToSubmittedIntegrationEventHandler>();
|
||||
|
||||
var app = builder.Build();
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
|
@ -28,8 +28,7 @@ public class IdentifiedCommandHandlerTest
|
||||
|
||||
//Act
|
||||
var handler = new CreateOrderIdentifiedCommandHandler(_mediator.Object, _requestManager.Object, _loggerMock.Object);
|
||||
var cltToken = new System.Threading.CancellationToken();
|
||||
var result = await handler.Handle(fakeOrderCmd, cltToken);
|
||||
var result = await handler.Handle(fakeOrderCmd, CancellationToken.None);
|
||||
|
||||
//Assert
|
||||
Assert.True(result);
|
||||
|
@ -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 HealthChecks.UI.Client;
|
||||
global using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
|
@ -12,7 +12,6 @@
|
||||
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" />
|
||||
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" />
|
||||
<PackageReference Include="Azure.Identity" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" />
|
||||
|
@ -15,7 +15,6 @@
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" />
|
||||
<PackageReference Include="Duende.IdentityServer.AspNetIdentity" />
|
||||
<PackageReference Include="Duende.IdentityServer.EntityFramework.Storage" />
|
||||
<PackageReference Include="Duende.IdentityServer.EntityFramework" />
|
||||
|
@ -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.Authorization;
|
||||
global using Microsoft.AspNetCore.Builder;
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace Webhooks.API;
|
||||
namespace Webhooks.API;
|
||||
public class Startup
|
||||
{
|
||||
public IConfiguration Configuration { get; }
|
||||
@ -26,10 +26,7 @@ public class Startup
|
||||
.AddTransient<IGrantUrlTesterService, GrantUrlTesterService>()
|
||||
.AddTransient<IWebhooksRetriever, WebhooksRetriever>()
|
||||
.AddTransient<IWebhooksSender, WebhooksSender>();
|
||||
|
||||
var container = new ContainerBuilder();
|
||||
container.Populate(services);
|
||||
return new AutofacServiceProvider(container.Build());
|
||||
return services.BuildServiceProvider();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
|
@ -12,7 +12,6 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user