Jinget.Core.DiScanner 6.2.19-preview018

Prefix Reserved
This is a prerelease version of Jinget.Core.DiScanner.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Jinget.Core.DiScanner --version 6.2.19-preview018                
NuGet\Install-Package Jinget.Core.DiScanner -Version 6.2.19-preview018                
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="6.2.19-preview018" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jinget.Core.DiScanner --version 6.2.19-preview018                
#r "nuget: Jinget.Core.DiScanner, 6.2.19-preview018"                
#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=6.2.19-preview018&prerelease

// Install Jinget.Core.DiScanner as a Cake Tool
#tool nuget:?package=Jinget.Core.DiScanner&version=6.2.19-preview018&prerelease                

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 net6.0 is compatible.  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. 
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
6.2.19-preview035 68 9/10/2024
6.2.19-preview034 74 9/9/2024
6.2.19-preview033 75 9/1/2024
6.2.19-preview032 80 9/1/2024
6.2.19-preview031 82 8/31/2024
6.2.19-preview029 82 8/26/2024
6.2.19-preview028 90 8/26/2024
6.2.19-preview027 93 8/26/2024
6.2.19-preview026 103 8/21/2024
6.2.19-preview025 98 8/21/2024
6.2.19-preview024 109 8/19/2024
6.2.19-preview023 97 8/8/2024
6.2.19-preview022 92 8/8/2024
6.2.19-preview021 79 8/5/2024
6.2.19-preview020 87 8/5/2024
6.2.19-preview019 82 8/5/2024
6.2.19-preview018 60 8/3/2024
6.2.19-preview017 51 7/30/2024
6.2.19-preview016 64 7/29/2024
6.2.19-preview015 66 7/29/2024
6.2.19-preview014 61 7/26/2024
6.2.19-preview013 96 7/20/2024
6.2.19-preview012 100 7/20/2024
6.2.19-preview011 97 6/15/2024
6.2.19-preview010 97 6/14/2024
6.2.19-preview009 87 6/14/2024
6.2.19-preview008 94 6/13/2024
6.2.19-preview007 90 6/13/2024
6.2.19-preview006 80 6/13/2024
6.2.19-preview005 91 6/13/2024
6.2.19-preview004 82 6/13/2024
6.2.19-preview003 84 6/11/2024
6.2.19-preview002 87 6/8/2024
6.2.19-preview001 84 6/8/2024
6.2.18 123 6/6/2024
6.2.18-preview020 89 6/6/2024
6.2.18-preview019 87 6/6/2024
6.2.18-preview018 88 6/6/2024
6.2.18-preview017 96 6/2/2024
6.2.18-preview016 85 6/1/2024
6.2.18-preview015 103 5/28/2024
6.2.18-preview014 90 5/28/2024
6.2.18-preview013 89 5/28/2024
6.2.18-preview012 91 5/28/2024
6.2.18-preview011 98 5/26/2024
6.2.18-preview010 94 5/26/2024
6.2.18-preview009 100 5/26/2024
6.2.18-preview008 102 5/26/2024
6.2.18-preview007 123 5/22/2024
6.2.18-preview006 100 5/22/2024
6.2.18-preview005 104 5/19/2024
6.2.18-preview004 97 5/19/2024
6.2.18-preview003 89 5/19/2024
6.2.18-preview002 92 5/19/2024
6.2.17 114 5/19/2024
6.2.16 106 5/18/2024
6.2.15 119 5/18/2024
6.2.14 107 5/18/2024
6.2.13 115 5/17/2024
6.2.12 122 5/17/2024
6.2.11 122 5/17/2024
6.2.10 119 5/17/2024
6.2.9 94 5/12/2024
6.2.8 101 5/9/2024
6.2.7 88 5/9/2024
6.2.6 123 5/7/2024
6.2.5 114 4/24/2024
6.2.4 129 2/1/2024
6.2.3 101 2/1/2024
6.2.2 103 1/31/2024
6.2.1 119 1/23/2024
6.2.0 105 1/23/2024
6.2.0-preview013 95 1/19/2024