AutoResolver 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AutoResolver --version 1.0.0                
NuGet\Install-Package AutoResolver -Version 1.0.0                
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.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AutoResolver --version 1.0.0                
#r "nuget: AutoResolver, 1.0.0"                
#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.0

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

AutoResolver

AutoResolver is a simple little library built to resolve classes bit more easily. Any class or interface can implement the following interfaces to register their class and resolve them in constructor or 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 IResolveAsTransient : IResolveTransient
    {
        string GetMessage();
    }
}
...

namespace AutoResolverTest
{
    public class ResolveAsTransient : IResolveAsTransient
    {
        public string GetMessage()
        {
            return "This class has been resolved successfully";
        }
    }
}

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

var myResolvedClass = serviceProvider.GetRequiredService<IResolveAsTransient>();
Console.WriteLine($"Text from resolved class: {myResolvedClass.GetMessage()}");
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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. 
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 420 6/21/2021
1.0.1 354 6/21/2021
1.0.0 333 6/20/2021