Skip to content

Commit

Permalink
readme updated
Browse files Browse the repository at this point in the history
  • Loading branch information
vahid committed Jan 19, 2024
1 parent c7c30a0 commit ba15395
Showing 1 changed file with 50 additions and 4 deletions.
54 changes: 50 additions & 4 deletions 01-Core/Jinget.Core.DiScanner/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

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

Expand All @@ -8,9 +9,54 @@ 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.

## 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

***FromCallingAssembly:***
> You can view more detailed sample by referring to `Jinget.CoreDiScanner.Test` project. [View UnitTests](https://github.com/VahidFarahmandian/Jinget/tree/main/Tests/Jinget.Core.DiScanner.Tests)
***Sample 1:***

Will scan for types from the calling assembly.

Expand All @@ -24,7 +70,7 @@ _services.Scan(

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:***
***Sample 2:***

Will scan for types from the calling assembly.

Expand All @@ -38,7 +84,7 @@ _services.Scan(

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:***
***Sample 3:***

```csharp
_services.Scan(
Expand All @@ -50,7 +96,7 @@ _services.Scan(

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:***
***Sample 4:***

```csharp
_services.Scan(
Expand Down

0 comments on commit ba15395

Please sign in to comment.