Autofac.EasyPropInject 2.0.0

dotnet add package Autofac.EasyPropInject --version 2.0.0                
NuGet\Install-Package Autofac.EasyPropInject -Version 2.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="Autofac.EasyPropInject" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Autofac.EasyPropInject --version 2.0.0                
#r "nuget: Autofac.EasyPropInject, 2.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 Autofac.EasyPropInject as a Cake Addin
#addin nuget:?package=Autofac.EasyPropInject&version=2.0.0

// Install Autofac.EasyPropInject as a Cake Tool
#tool nuget:?package=Autofac.EasyPropInject&version=2.0.0                

Nuget Paypal Donate Github

Important!

Due to new Autofac v.8 Version - older versions stay as they are. Updates only occur to latest version released.

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

Contribute / Donations

If you got any Ideas to improve my projects feel free to send an pull request.

If you like my work and want to support me (or want to buy me a coffee/beer) paypal donation are more than appreciated.

Paypal Donate

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 your 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] //Since Autofac.EasyPropInject@1.2.5: Support for protected properties
    protected IMyService serviceProtected {get;set;}

    [FromAutofac] //Since Autofac.EasyPropInject@1.2.5: Support for private properties
    private IMyService2 servicePrivate {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?

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.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Upgraded to Autofac 8.x