Skip to content

Commit

Permalink
2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dariogriffo committed Sep 1, 2024
1 parent 5e3326b commit d7b913b
Show file tree
Hide file tree
Showing 31 changed files with 675 additions and 199 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ services.AutoRegisterTypesInAssemblies(new RegistratorConfiguration()


By default all registered types are registered as `ServiceLifetime.Scoped`, but you can change it by passing a `ServiceLifetime` as a parameter of the attribute.

You can also add keyed services if you use the `Key` property of the attribute.
~~~~
~~~~
## License

[MIT](https://github.com/dariogriffo/registator-net/blob/main/LICENSE)
Expand Down
6 changes: 6 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release Notes


## [2.0.0](https://github.com/dariogriffo/registator-net/1.1.1)

Target net8.0 only.

Added support for Keyed services

## [1.1.1](https://github.com/dariogriffo/registator-net/1.1.1)

Updated docs and added a new example to the README.md
Expand Down
7 changes: 7 additions & 0 deletions Registrator.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Registrator.Net", "src\Regi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Registrator.Net.Tests", "tests\Registrator.Net.Tests\Registrator.Net.Tests.csproj", "{3E23AD31-68A7-4236-87A5-4EA9572ACE19}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmarker", "tests\Benchmarker\Benchmarker.csproj", "{4C0EF845-D213-4988-BAA9-4DE0A9D7F47E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -25,6 +27,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{C0348AC1-9A06-45C2-B1CC-7C7F91229170} = {BA907559-7545-40C5-BF46-D18A8098A5B6}
{3E23AD31-68A7-4236-87A5-4EA9572ACE19} = {2B54C5C3-377D-421F-AA0E-EBC09F299FB9}
{4C0EF845-D213-4988-BAA9-4DE0A9D7F47E} = {2B54C5C3-377D-421F-AA0E-EBC09F299FB9}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C0348AC1-9A06-45C2-B1CC-7C7F91229170}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand All @@ -35,5 +38,9 @@ Global
{3E23AD31-68A7-4236-87A5-4EA9572ACE19}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E23AD31-68A7-4236-87A5-4EA9572ACE19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E23AD31-68A7-4236-87A5-4EA9572ACE19}.Release|Any CPU.Build.0 = Release|Any CPU
{4C0EF845-D213-4988-BAA9-4DE0A9D7F47E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C0EF845-D213-4988-BAA9-4DE0A9D7F47E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C0EF845-D213-4988-BAA9-4DE0A9D7F47E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C0EF845-D213-4988-BAA9-4DE0A9D7F47E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
12 changes: 9 additions & 3 deletions src/Registrator.Net/AutoRegisterInterfaces.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Registrator.Net;

using Microsoft.Extensions.DependencyInjection;
using System;
using Microsoft.Extensions.DependencyInjection;

/// <summary>
/// Attribute to automatically register all the interfaces of the type with the DI container.
Expand All @@ -10,13 +10,19 @@ namespace Registrator.Net;
public class AutoRegisterInterfaces : Attribute
{
internal ServiceLifetime Lifetime { get; }
internal object? Key { get; }

/// <summary>
/// Initializes a new instance of the <see cref="AutoRegisterInterfaces"/> class.
/// </summary>
/// <param name="lifetime"></param>
public AutoRegisterInterfaces(ServiceLifetime lifetime = ServiceLifetime.Scoped)
/// <param name="lifetime">The <see cref="ServiceLifetime"/> assigned to the class resolving interfaces</param>
/// <param name="key">An optional key to register the class</param>
public AutoRegisterInterfaces(
ServiceLifetime lifetime = ServiceLifetime.Scoped,
object? key = null
)
{
Lifetime = lifetime;
Key = key;
}
}
11 changes: 7 additions & 4 deletions src/Registrator.Net/AutoRegisterType.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Registrator.Net;

using Microsoft.Extensions.DependencyInjection;
using System;
using Microsoft.Extensions.DependencyInjection;

/// <summary>
/// Attribute to automatically register a type with the DI container.
Expand All @@ -10,13 +10,16 @@ namespace Registrator.Net;
public class AutoRegisterType : Attribute
{
internal ServiceLifetime Lifetime { get; }
internal object? Key { get; }

/// <summary>
/// Initializes a new instance of the <see cref="AutoRegisterType"/> class.
/// Initializes a new instance of the <see cref="AutoRegisterInterfaces"/> class.
/// </summary>
/// <param name="lifetime"></param>
public AutoRegisterType(ServiceLifetime lifetime = ServiceLifetime.Scoped)
/// <param name="lifetime">The <see cref="ServiceLifetime"/> assigned to the class resolving the type</param>
/// <param name="key">An optional key to register the class</param>
public AutoRegisterType(ServiceLifetime lifetime = ServiceLifetime.Scoped, object? key = null)
{
Lifetime = lifetime;
Key = key;
}
}
13 changes: 9 additions & 4 deletions src/Registrator.Net/AutoRegisterTypeAndInterfaces.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Registrator.Net;

using Microsoft.Extensions.DependencyInjection;
using System;
using Microsoft.Extensions.DependencyInjection;

/// <summary>
/// Attribute to automatically register a type and its interfaces with the DI container.
Expand All @@ -10,14 +10,19 @@ namespace Registrator.Net;
public class AutoRegisterTypeAndInterfaces : Attribute
{
internal ServiceLifetime Lifetime { get; }

internal object? Key { get; }

/// <summary>
/// Initializes a new instance of the <see cref="AutoRegisterTypeAndInterfaces"/> class.
/// </summary>
/// <param name="lifetime"></param>
public AutoRegisterTypeAndInterfaces(ServiceLifetime lifetime = ServiceLifetime.Scoped)
/// <param name="lifetime">The <see cref="ServiceLifetime"/> assigned to the class resolving the type and interfaces</param>
/// <param name="key">An optional key to register the class</param>
public AutoRegisterTypeAndInterfaces(
ServiceLifetime lifetime = ServiceLifetime.Scoped,
object? key = null
)
{
Lifetime = lifetime;
Key = key;
}
}
8 changes: 4 additions & 4 deletions src/Registrator.Net/Registrator.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<NeutralLanguage>en-GB</NeutralLanguage>

<!-- Build settings -->
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<DebugType>portable</DebugType>
<OutputType>Library</OutputType>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -28,8 +28,8 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/dariogriffo/registrator-net</RepositoryUrl>
<Version>1.1.1</Version>
<AssemblyVersion>1.1.1</AssemblyVersion>
<Version>2.0.0</Version>
<AssemblyVersion>2.0.0</AssemblyVersion>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<!-- SourceLink settings -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
Expand All @@ -56,7 +56,7 @@


<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="[2.0.0,)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="[8.0.0,)" />
</ItemGroup>


Expand Down
4 changes: 2 additions & 2 deletions src/Registrator.Net/RegistratorConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ namespace Registrator.Net;
using System.Reflection;

/// <summary>
/// The configuration for the registrator.
/// The configuration for the registrator.
/// </summary>
public class RegistratorConfiguration
{
/// <summary>
/// Assemblies to scan for types to register.
/// </summary>
public Assembly[] Assemblies { get; set; } = Array.Empty<Assembly>();

/// <summary>
/// Assemblies to exclude interfaces from register on types declared in <see cref="Assemblies"/>.
/// </summary>
Expand Down
Loading

0 comments on commit d7b913b

Please sign in to comment.