Autofac.EasyPropInject 1.2.2

Install-Package Autofac.EasyPropInject -Version 1.2.2
dotnet add package Autofac.EasyPropInject --version 1.2.2
<PackageReference Include="Autofac.EasyPropInject" Version="1.2.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Autofac.EasyPropInject --version 1.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Autofac.EasyPropInject, 1.2.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 Autofac.EasyPropInject as a Cake Addin
#addin nuget:?package=Autofac.EasyPropInject&version=1.2.2

// Install Autofac.EasyPropInject as a Cake Tool
#tool nuget:?package=Autofac.EasyPropInject&version=1.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Nuget

Important!

Due to breaking changes to Autofac API with version 6.x older Autofac.EasyPropInject Readme can be found in 1.0.x (Autofac ⇐4>) and 1.1.x (Autofac >=5 < 6>). master and 1.2.x will show code examples and info only for Autofac >= 6.

Autofac.EasyPropInject

An extension i created to make it possible to to inject properties by attribute, without any other helper libs in .NET Core for Autofac.

Install

Nuget

Install-Package Autofac.EasyPropInject

DotNetCli

dotnet add package Autofac.EasyPropInject

Usage

Startup.cs

Go to "ConfigureServices" Make sure that you create the Autofac Container as usual for your Framework (Supported is .NET Standard 2+) like its described here: https://autofac.readthedocs.io/en/latest/integration/index.html

and then you create the instance BEFORE any registration.

   public IServiceProvider ConfigureServices(IServiceCollection services)
   {
          ......
          var builder = new ContainerBuilder().AddEasyPropInject();
          
          //Add you services now as usual 
    }
    

Usage in the Code

using Autofac.EasyPropInject.Annotations;
public class MyClass:IMyInterface 
{ 
    public MyClass(ISomeOtherInterface someService) 
    { 
      
    }
    
    [FromAutofac]
    public IUnitOfWork unit { get;set; }

    [FromAutofac(typeof(IUnitOfWork))]
    public UnitOfWorkBaseClass unit2 {get;set;}
}

Once IMyInterface is resolved and activated EasyPropInject Middleware will try to resolve the types of unit and unit2. In this case EasyPropInject will try to resolve IUnitOfWork from current container and will try to set and Instance of IUnitOfWork to unit2 and use it as UnitOfWorkBaseClass. Warning Since the type casting feature new in 1.2.x of EasyPropInject is handy sometimes its truly unsafe and you should to be sure what you are doing.

Whats new?

  • 1.2.0 - Implemented Easy Prop Inject for Autofac 6.x and added the feature to load an property as different type from IContainer. See FromAutofacAttribute.
  • 1.1.1 - Easy Prop Inject now supports Autofac 5.x
  • 1.0.0 - Added Tests
  • .NETStandard 2.0

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.2.2 236 10/18/2020
1.2.1 162 10/15/2020
1.2.0 171 10/15/2020
1.1.1 165 10/15/2020
1.1.0 163 10/15/2020
1.0.4 152 10/15/2020
1.0.1 163 10/15/2020
1.0.0 488 9/30/2018

Added project information to github repository and minore infos.