AutoResolver 1.0.2

dotnet add package AutoResolver --version 1.0.2
NuGet\Install-Package AutoResolver -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AutoResolver" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AutoResolver --version 1.0.2
#r "nuget: AutoResolver, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AutoResolver as a Cake Addin
#addin nuget:?package=AutoResolver&version=1.0.2

// Install AutoResolver as a Cake Tool
#tool nuget:?package=AutoResolver&version=1.0.2

AutoResolver

AutoResolver is a simple library built to resolve services bit more easily. Any class or interface can implement the following interfaces to register their class and resolve them through service provider.

  • IResolveTransient to register the class with lifetime as transient.
  • IResolveScoped to register the class with lifetime as scoped.
  • IResolveSingleton to register the class with lifetime as singleton.

How do I get started?

First add the AutoResolver to the service collection.

...
services.AddAutoResolver();
services.AddMvc();
services.AddJwtTokenAuthentication();
....

OR

var serviceProvider = new ServiceCollection()
                .AddAutoResolver()
                .BuildServiceProvider();

Then implement the desired interface to register them with Microsoft.Extensions.DependencyInjection.

using AutoResolver;

namespace AutoResolverTest
{
    public interface IThisAsTransient : IResolveTransient
    {
        string GetMessage();
    }
}
...

namespace AutoResolverTest
{
    public class ThisAsTransient : IThisAsTransient
    {
        public string GetMessage()
        {
            return "Hi from resolved service (transient)";
        }
    }
}

Now you are done. You can now use the service provider (or inject) to resolve the service.

var myResolvedClass = serviceProvider.GetRequiredService<IThisAsTransient>();
Console.WriteLine($"Text from resolved class: {myResolvedClass.GetMessage()}");
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 378 6/21/2021
1.0.1 326 6/21/2021
1.0.0 310 6/20/2021