AutoResolver 1.0.2

Install-Package AutoResolver -Version 1.0.2
dotnet add package AutoResolver --version 1.0.2
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AutoResolver, 1.0.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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()}");

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 89 6/21/2021
1.0.1 98 6/21/2021
1.0.0 89 6/20/2021