TravelGate.Extensions.DependencyInjection.AutoWire 2.0.0

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

// Install TravelGate.Extensions.DependencyInjection.AutoWire as a Cake Tool
#tool nuget:?package=TravelGate.Extensions.DependencyInjection.AutoWire&version=2.0.0

AutoWire

Library to auto register dependencies and to auto bind option classes for Microsoft.Extensions.DependencyInjection

Getting Started

Just call AutoWire on your service collection, like:

serviceCollection.AutoWire(config);

Where config is of type IConfiguration.

Usually that's all you need. AutoWire will auto register types as services and options if the following applies:

For services
  • They are classes, including generics with open type (SomeType<>).
  • They belong to the entry assembly as obtained by Assembly.GetEntryAsembly().
  • They are not marked with or inherit [IgnoreAutoWire] attribute.
  • They are not abstract or nested.
  • They don't end with "Options".
For options
  • They are classes.
  • They have a parameter-less constructor.
  • Their name match a section from the provided IConfiguration object.

Additional features

Use IncludePrefixed option

Using this option only classes under to the IEnumerable<string> namespace prefixes are added.

var sc = new ServiceCollection();
sc.AutoWire(config, options => options.IncludePrefixed = new[] { typeof(SomeClass).Namespace });

For example, assuming that someClass belongs to ProjectName.Folder, all classes located in the same namespace will be registered.

Use RegisterByAttribute option
var sc = new ServiceCollection();
sc.AutoWire(config, options => options.RegisterByAttribute = true);

Using this option only classes that are marked with or inherit [AutoWire] are registered. For example:

[AutoWire]
public class SomeClass {}

NOTE: if both IncludePrefixed and RegisterByAttribute, they are both applied and in this order.

Ignoring classes

If you wish to ignore a class or derived classes from a base class or interface, mark the class, base class or interface with [IgnoreAutoWire], for example:

[IgnoreAutoWire]
public class SomeClass {}

Contribute

Yes please!

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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.

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
2.0.0 806 2/26/2020