Skip to content

Commit

Permalink
Merge pull request #6 from futurum-dev/feature/improve-README.md
Browse files Browse the repository at this point in the history
Improve README.md.
  • Loading branch information
futurum-dev authored Apr 7, 2023
2 parents 6107966 + 7f1e1d9 commit e568731
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 7 deletions.
72 changes: 69 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,76 @@
# Futurum.Microsoft.Extensions.DependencyInjection

![license](https://img.shields.io/github/license/futurum-dev/dotnet.futurum.microsoft.extensions.dependencyinjection?style=for-the-badge)
![CI](https://img.shields.io/github/workflow/status/futurum-dev/dotnet.futurum.microsoft.extensions.dependencyinjection/CI/main?style=for-the-badge)
![CI](https://img.shields.io/github/actions/workflow/status/futurum-dev/dotnet.futurum.microsoft.extensions.dependencyinjection/ci.yml?branch=main&style=for-the-badge)
[![Coverage Status](https://img.shields.io/coveralls/github/futurum-dev/dotnet.futurum.microsoft.extensions.dependencyinjection?style=for-the-badge)](https://coveralls.io/github/futurum-dev/dotnet.futurum.microsoft.extensions.dependencyinjection?branch=main)
[![NuGet version](https://img.shields.io/nuget/v/futurum.microsoft.extensions.dependencyinjection?style=for-the-badge)](https://www.nuget.org/packages/futurum.microsoft.extensions.dependencyinjection)

A dotnet library, that allows Microsoft.Extensions.DependencyInjection to work with Futurum.Core.
A dotnet library, that allows Microsoft.Extensions.DependencyInjection to work with Futurum.Core. It also adds support for modules and startables.

It also adds support for modules and startables.
## TryGetService
Try to get the service object of the specified type.

```csharp
var result = serviceProvider.TryGetService<ITestService>();
```

## Modules
A module allows you to break up registration into logical units.

### IModule interface
Implements this interface to create a module.

```csharp
public class TestModule : IModule
{
public void Load(IServiceCollection services)
{
services.AddSingleton<ITestService, TestService>();
}
}
```

### RegisterModule extension method
Allows you to register a module.

```csharp
services.RegisterModule<TestModule>();
```

```csharp
services.RegisterModule(new TestModule());
```

## Startables
A startable is resolved at the start of the application lifecycle and is a place to perform actions as soon as the DependencyInjection container is built.

### IStartable interface
Implements this interface to create a startable.

```csharp
public class TestStartable : IStartable
{
public void Start()
{
// Do something
}
}
```

### AddStartable extension method
Allows you to register a startable.

```csharp
services.AddStartable<TestStartable>();
```

```csharp
services.AddStartable(new TestStartable());
```

### BuildServiceProviderWithStartables extension method
Creates a ServiceProvider containing services from the provided IServiceCollection and starts all *IStartable* instances.

```csharp
var serviceProvider = services.BuildServiceProviderWithStartables();
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PropertyGroup>
<PackageId>Futurum.Microsoft.Extensions.DependencyInjection</PackageId>
<PackageIcon>dotnet-logo.png</PackageIcon>
<Description>A dotnet library, that allows Microsoft.Extensions.DependencyInjection to work with Futurum.Core. It also add modules and startables.</Description>
<Description>A dotnet library, that allows Microsoft.Extensions.DependencyInjection to work with Futurum.Core. It also adds support for modules and startables.</Description>
<PackageProjectUrl>https://www.futurum.dev/projects/dotnet-futurum.html</PackageProjectUrl>
<RepositoryUrl>https://github.com/futurum-dev/dotnet.futurum.microsoft.extensions.dependencyinjection</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand All @@ -28,7 +28,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Futurum.Core" Version="1.0.11" />
<PackageReference Include="Futurum.Core" Version="1.0.15" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Update="MinVer" Version="4.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Futurum.Test" Version="1.0.4" />
<PackageReference Include="Futurum.Test" Version="1.0.6" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit e568731

Please sign in to comment.