-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vahid
committed
Jan 19, 2024
1 parent
0249695
commit c7c30a0
Showing
8 changed files
with
441 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Jinget.Core.DiScanner | ||
Using this library, you can easily register your source code dependencies automatically without the need to write repetitive and annoying codes. | ||
|
||
|
||
## 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](https://www.nuget.org/packages/Jinget.Core.DiScanner"Here") for more information. | ||
|
||
## Samples | ||
|
||
***FromCallingAssembly:*** | ||
|
||
Will scan for types from the calling assembly. | ||
|
||
```csharp | ||
_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. | ||
|
||
***FromExecutingAssembly:*** | ||
|
||
Will scan for types from the calling assembly. | ||
|
||
```csharp | ||
_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. | ||
|
||
***FromAssembliesOf:*** | ||
|
||
```csharp | ||
_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 | ||
|
||
***FromAssemblies:*** | ||
|
||
```csharp | ||
_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](https://www.nuget.org/packages/Jinget.Core.DiScanner "nuget.org") | ||
|
||
## Contact Me | ||
👨💻 Twitter: https://twitter.com/_jinget | ||
|
||
📧 Email: [email protected] | ||
|
||
📣 Instagram: https://www.instagram.com/vahidfarahmandian |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.