Tedd.ModuleLoader 1.0.1

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

// Install Tedd.ModuleLoader as a Cake Tool
#tool nuget:?package=Tedd.ModuleLoader&version=1.0.1                

Dependency

References Microsoft.Extensions.DependencyInjection.Abstractions for AddScoped<T>, AddTransient<T> and AddSingleton<T>. References Microsoft.Extensions.Hosting.Abstractions to reference IHostedService in AddHostedService<T>.

Examples

Create instances directly

Load all files in directory (with default filter of *.dll). Create an instance of all classes that inherit from ICalcModule.

var modules = AssemblyLoader.LoadDirectory(".").CreateInstances<ICalcModule>();

or if ctor requires arguments

var modules = AssemblyLoader.LoadDirectory(".").CreateInstances<ICtorArgsModule>(new object[] { "Test", 123 });

Get TypeInfo

Load all files in directory (with default filter of *.dll). Find TypeInfo for all classes that inherit from ICalcModule.

var types = AssemblyLoader.LoadDirectory(".").GetTypeInfoOf<ICalcModule>();

Create instance from TypeInfo

types.CreateInstances<ICalcModule>()

Dependency injection

services.AddScoped<ICalcModule>(AssemblyLoader.LoadDirectory("."));

or

services.AddTransient<ICalcModule>(AssemblyLoader.LoadDirectory("."));

or

services.AddSingleton<ICalcModule>(AssemblyLoader.LoadDirectory("."));

Filter what files to load

  • .Net Directory.GetFiles filter: AssemblyLoader.LoadDirectory(".", "*.Module1.dll")
  • Regex filter, case insensitive: AssemblyLoader.LoadDirectory(".", @"Test.*Module1\.dll$", false)
  • Regex filter, case sensitive: AssemblyLoader.LoadDirectory(".", @"Test.*Module1\.dll$", true)
  • Custom list of files: AssemblyLoader.LoadDirectory(files) where files is an IEnumerable (i.e. List, Array or LINQ result) of string.
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 is compatible.  netcoreapp2.1 is compatible.  netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 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.1 645 5/14/2019
1.0.0 532 5/14/2019

Added AddHostedService<T>