Skip to content

Commit 955ad88

Browse files
committed
IServiceCollection was removed. Just use WebApplicationBuilder.Services please.
1 parent dcae84a commit 955ad88

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

src/Calabonga.AspNetCore.AppDefinitions/AppDefinition.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.AspNetCore.Builder;
2-
using Microsoft.Extensions.DependencyInjection;
32

43
namespace Calabonga.AspNetCore.AppDefinitions;
54

@@ -11,9 +10,8 @@ public abstract class AppDefinition : IAppDefinition
1110
/// <summary>
1211
/// Configure services for current application
1312
/// </summary>
14-
/// <param name="services">instance of <see cref="IServiceCollection"/></param>
1513
/// <param name="builder">instance of <see cref="WebApplicationBuilder"/></param>
16-
public virtual void ConfigureServices(IServiceCollection services, WebApplicationBuilder builder) { }
14+
public virtual void ConfigureServices(WebApplicationBuilder builder) { }
1715

1816
/// <summary>
1917
/// Configure application for current application

src/Calabonga.AspNetCore.AppDefinitions/AppDefinitionExtensions.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,21 @@ public static class AppDefinitionExtensions
1313
/// <remarks>
1414
/// When executing on development environment there are more diagnostic information available on console.
1515
/// </remarks>
16-
/// <param name="source"></param>
1716
/// <param name="builder"></param>
1817
/// <param name="entryPointsAssembly"></param>
19-
public static void AddDefinitions(this IServiceCollection source, WebApplicationBuilder builder, params Type[] entryPointsAssembly)
18+
public static void AddDefinitions(this WebApplicationBuilder builder, params Type[] entryPointsAssembly)
2019
{
21-
var logger = source.BuildServiceProvider().GetRequiredService<ILogger<AppDefinition>>();
20+
var logger = builder.Services.BuildServiceProvider().GetRequiredService<ILogger<AppDefinition>>();
2221
var definitions = new List<IAppDefinition>();
23-
var appDefinitionInfo = source.BuildServiceProvider().GetService<AppDefinitionCollection>();
22+
var appDefinitionInfo = builder.Services.BuildServiceProvider().GetService<AppDefinitionCollection>();
2423
var info = appDefinitionInfo ?? new AppDefinitionCollection();
2524

2625
foreach (var entryPoint in entryPointsAssembly)
2726
{
2827
info.AddEntryPoint(entryPoint.Name);
2928

30-
3129
var types = entryPoint.Assembly.ExportedTypes.Where(x => !x.IsAbstract && typeof(IAppDefinition).IsAssignableFrom(x));
3230
var instances = types.Select(Activator.CreateInstance).Cast<IAppDefinition>().ToList();
33-
//if (logger.IsEnabled(LogLevel.Debug))
34-
//{
35-
// logger.LogDebug("AppDefinitions Founded: {@AppDefinitionsCountTotal}.", instances.Count);
36-
//}
3731

3832
foreach (var definition in instances)
3933
{
@@ -46,7 +40,7 @@ public static void AddDefinitions(this IServiceCollection source, WebApplication
4640

4741
foreach (var definition in definitions)
4842
{
49-
definition.ConfigureServices(source, builder);
43+
definition.ConfigureServices(builder);
5044
}
5145
if (logger.IsEnabled(LogLevel.Debug))
5246
{
@@ -59,7 +53,7 @@ public static void AddDefinitions(this IServiceCollection source, WebApplication
5953
}
6054
}
6155

62-
source.AddSingleton(info);
56+
builder.Services.AddSingleton(info);
6357
}
6458

6559
/// <summary>

src/Calabonga.AspNetCore.AppDefinitions/Calabonga.AspNetCore.AppDefinitions.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Nullable>enable</Nullable>
77
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
88
<Title>Calabonga.AspNetCore.AppDefinitions</Title>
9-
<Version>1.3.0</Version>
9+
<Version>2.0.0-beta1</Version>
1010
<Authors>Calabonga</Authors>
1111
<Company>Calabonga Soft</Company>
1212
<Product>Calabonga.AspNetCore.AppDefinitions</Product>
@@ -18,7 +18,7 @@
1818
<RepositoryUrl>https://github.com/Calabonga/Calabonga.AspNetCore.AppDefinitions</RepositoryUrl>
1919
<RepositoryType>git</RepositoryType>
2020
<PackageTags>calabonga;architecture;definitions;minimal-api;nimble-framework</PackageTags>
21-
<PackageReleaseNotes>AppDefinitions new registration information on debug model was implemented</PackageReleaseNotes>
21+
<PackageReleaseNotes>IServiceCollection was removed. Just use WebApplicationBuilder.Services please.</PackageReleaseNotes>
2222
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2323
</PropertyGroup>
2424

src/Calabonga.AspNetCore.AppDefinitions/IAppDefinition.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.AspNetCore.Builder;
2-
using Microsoft.Extensions.DependencyInjection;
32

43
namespace Calabonga.AspNetCore.AppDefinitions;
54

@@ -11,9 +10,8 @@ public interface IAppDefinition
1110
/// <summary>
1211
/// Configure services for current application
1312
/// </summary>
14-
/// <param name="services">instance of <see cref="IServiceCollection"/></param>
1513
/// <param name="builder">instance of <see cref="WebApplicationBuilder"/></param>
16-
void ConfigureServices(IServiceCollection services, WebApplicationBuilder builder);
14+
void ConfigureServices(WebApplicationBuilder builder);
1715

1816
/// <summary>
1917
/// Configure application for current application

0 commit comments

Comments
 (0)