Jinget.Core.DiScanner 8.0.0

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

// Install Jinget.Core.DiScanner as a Cake Tool
#tool nuget:?package=Jinget.Core.DiScanner&version=8.0.0                

Jinget.Core.DiScanner

Using this library, you can easily register your source code dependencies automatically without the need to write repetitive and annoying codes.

Attention: This package is build based on Autofac assembly scanning.

How to Use:

Download the package from NuGet using Package Manager: Install-Package Jinget.Core.DiScanner You can also use other methods supported by NuGet. Check Here for more information.

Methods

Assembly Selector

Name Description
FromCallingAssembly Will scan for types from the calling assembly
FromExecutingAssembly Will scan for types from the currently executing assembly
FromEntryAssembly Will scan for types from the entry assembly
FromApplicationDependencies Will load and scan all runtime libraries referenced by the currently executing application
FromAssemblyDependencies Will load and scan all runtime libraries referenced by the currently specified assembly
FromDependencyContext Will load and scan all runtime libraries in the given context
FromAssemblyOf Will scan for types from the assembly of type T
FromAssemblies Will scan for types in each Assembly in assemblies

Service Type Selector

Name Description
AsSelf Registers each matching concrete type as itself
FromExecutingAssembly Will scan for types from the currently executing assembly
As Registers each matching concrete type
AsImplementedInterfaces Registers each matching concrete type as all of its implemented interfaces
AsSelfWithInterfaces Registers each matching concrete type as all of its implemented interfaces, by returning an instance of the main type
AsMatchingInterface Registers the type with the first found matching interface name. (e.g. ClassName is matched to IClassName)
UsingAttributes Registers each matching concrete type according to their ServiceDescriptorAttribute

Implementation Type Selector

Name Description
AddClasses Adds all non-abstract classes from the selected assemblies to the Microsoft.Extensions.DependencyInjection.IServiceCollection

Lifetime Selector

Name Description
WithSingletonLifetime Registers each matching concrete type with ServiceLifetime.Singleton lifetime
WithScopedLifetime Registers each matching concrete type with ServiceLifetime.Scoped lifetime
WithTransientLifetime Registers each matching concrete type with ServiceLifetime.Transient lifetime
WithLifetime Registers each matching concrete type with the specified lifetime

Samples

You can view more detailed sample by referring to Jinget.CoreDiScanner.Test project. View UnitTests

Sample 1:

Will scan for types from the calling assembly.

_services.Scan(
    s => s.FromCallingAssembly()
        .AddClasses()
        .AsImplementedInterfaces()
        .WithTransientLifetime());

The above code will scan the calling assembly and registers each matching concrete type as all of its implemented interfaces. WithTransientLifetime indicates that the services should have Transient lifetime.

Sample 2:

Will scan for types from the calling assembly.

_services.Scan(
    s => s.FromExecutingAssembly()
        .AddClasses()
        .AsImplementedInterfaces()
        .WithTransientLifetime());

The above code will scan for types from the currently executing assembly, and registers each matching concrete type as all of its implemented interfaces.

Sample 3:

_services.Scan(
    s => s.FromAssembliesOf(typeof(Sample))
        .AddClasses()
        .AsSelfWithInterfaces()
        .WithSingletonLifetime());

The above code will scan the assembly containing the Sample type and registers each matching concrete type as all of its implemented interfaces, by returning an instance of the main type

Sample 4:

_services.Scan(
    s => s.FromAssemblies(typeof(ICustomInterface).Assembly, typeof(ISelector).Assembly)
        .AddClasses()
        .AsImplementedInterfaces()
        .WithTransientLifetime());

The above code will scan for types in each assembly in assemblies, and registers each matching concrete type as all of its implemented interfaces, by returning an instance of the main type


How to install

In order to install Jinget.Core.DiScanner please refer to nuget.org

Contact Me

👨‍💻 Twitter: https://twitter.com/_jinget

📧 Email: farahmandian2011@gmail.com

📣 Instagram: https://www.instagram.com/vahidfarahmandian

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.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
8.0.0 95 1/22/2025
8.0.0-preview013 175 12/19/2024
8.0.0-preview012 79 12/19/2024
8.0.0-preview011 81 12/17/2024
8.0.0-preview010 85 12/16/2024
8.0.0-preview009 79 12/15/2024
8.0.0-preview008 92 11/25/2024
8.0.0-preview007 121 11/11/2024
8.0.0-preview006 98 11/2/2024
8.0.0-preview005 74 11/2/2024
8.0.0-preview004 74 11/1/2024
8.0.0-preview003 75 11/1/2024
8.0.0-preview002 77 11/1/2024
8.0.0-preview001 79 11/1/2024
6.2.23-preview003 71 10/31/2024
6.2.23-preview002 75 10/31/2024
6.2.22 118 10/26/2024
6.2.21 92 10/26/2024
6.2.20 103 10/26/2024
6.2.19-preview037 80 10/14/2024
6.2.19-preview036 82 9/30/2024
6.2.19-preview035 88 9/10/2024
6.2.19-preview034 93 9/9/2024
6.2.19-preview033 93 9/1/2024
6.2.19-preview032 95 9/1/2024
6.2.19-preview031 97 8/31/2024
6.2.19-preview029 94 8/26/2024
6.2.19-preview028 108 8/26/2024
6.2.19-preview027 110 8/26/2024
6.2.19-preview026 120 8/21/2024
6.2.19-preview025 113 8/21/2024
6.2.19-preview024 122 8/19/2024
6.2.19-preview023 107 8/8/2024
6.2.19-preview022 104 8/8/2024
6.2.19-preview021 92 8/5/2024
6.2.19-preview020 101 8/5/2024
6.2.19-preview019 94 8/5/2024
6.2.19-preview018 78 8/3/2024
6.2.19-preview017 61 7/30/2024
6.2.19-preview016 76 7/29/2024
6.2.19-preview015 76 7/29/2024
6.2.19-preview014 73 7/26/2024
6.2.19-preview013 109 7/20/2024
6.2.19-preview012 113 7/20/2024
6.2.19-preview011 106 6/15/2024
6.2.19-preview010 111 6/14/2024
6.2.19-preview009 98 6/14/2024
6.2.19-preview008 107 6/13/2024
6.2.19-preview007 105 6/13/2024
6.2.19-preview006 93 6/13/2024
6.2.19-preview005 102 6/13/2024
6.2.19-preview004 95 6/13/2024
6.2.19-preview003 97 6/11/2024
6.2.19-preview002 98 6/8/2024
6.2.19-preview001 98 6/8/2024
6.2.18 142 6/6/2024
6.2.18-preview020 98 6/6/2024
6.2.18-preview019 98 6/6/2024
6.2.18-preview018 101 6/6/2024
6.2.18-preview017 108 6/2/2024
6.2.18-preview016 101 6/1/2024
6.2.18-preview015 114 5/28/2024
6.2.18-preview014 103 5/28/2024
6.2.18-preview013 104 5/28/2024
6.2.18-preview012 106 5/28/2024
6.2.18-preview011 114 5/26/2024
6.2.18-preview010 122 5/26/2024
6.2.18-preview009 113 5/26/2024
6.2.18-preview008 115 5/26/2024
6.2.18-preview007 137 5/22/2024
6.2.18-preview006 113 5/22/2024
6.2.18-preview005 117 5/19/2024
6.2.18-preview004 118 5/19/2024
6.2.18-preview003 100 5/19/2024
6.2.18-preview002 103 5/19/2024
6.2.17 131 5/19/2024
6.2.16 129 5/18/2024
6.2.15 140 5/18/2024
6.2.14 122 5/18/2024
6.2.13 130 5/17/2024
6.2.12 139 5/17/2024
6.2.11 139 5/17/2024
6.2.10 135 5/17/2024
6.2.9 109 5/12/2024
6.2.8 116 5/9/2024
6.2.7 103 5/9/2024
6.2.6 139 5/7/2024
6.2.5 125 4/24/2024
6.2.4 140 2/1/2024
6.2.3 113 2/1/2024
6.2.2 117 1/31/2024
6.2.1 132 1/23/2024
6.2.0 119 1/23/2024
6.2.0-preview013 104 1/19/2024