https://github.com/fluxera/fluxera.extensions
A library that extends the Microsoft.Extensions.* libraries with custom functionality and also provides custom extensions.
https://github.com/fluxera/fluxera.extensions
dependency-injection dotnet dotnet6 dotnet7 dotnet8 microsoft-extensions microsoft-extensions-caching-memory microsoft-extensions-configuration microsoft-extensions-di microsoft-extensions-http microsoft-extensions-localization microsoft-extensions-logging validation
Last synced: about 1 year ago
JSON representation
A library that extends the Microsoft.Extensions.* libraries with custom functionality and also provides custom extensions.
- Host: GitHub
- URL: https://github.com/fluxera/fluxera.extensions
- Owner: fluxera
- License: mit
- Created: 2021-12-11T13:01:10.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-14T15:14:56.000Z (over 1 year ago)
- Last Synced: 2024-11-14T15:46:42.445Z (over 1 year ago)
- Topics: dependency-injection, dotnet, dotnet6, dotnet7, dotnet8, microsoft-extensions, microsoft-extensions-caching-memory, microsoft-extensions-configuration, microsoft-extensions-di, microsoft-extensions-http, microsoft-extensions-localization, microsoft-extensions-logging, validation
- Language: C#
- Homepage:
- Size: 307 KB
- Stars: 9
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://dev.azure.com/fluxera/Foundation/_build/latest?definitionId=85&branchName=main)
## Fluxera.Extensions
A library that extends the Microsoft.Extensions.* libraries with custom functionality and also provices custom extensions.
### ```Fluxera.Extensions.Caching```
This extension contains ```Option``` classes for configuring a remote distributed cache server and
several useful extension methods for the ```IDistributedCache``` service.
### ```Fluxera.Extensions.Common```
This extension contains several custom services:
- ```IDateTimeOffsetProvider``` A service that provides mockable access to static ```DateTimeOffset```.
- ```IDateTimeProvider``` A service that provides mockable access to static ```DateTime```.
- ```IGuidGenerator``` A service to generate ```Guid``` using different generators.
- ```IHashCalculator``` A service to calculate hashes from input values.
- ```IJitterCalculator``` A service that adds entropy to any given number.
- ```IPasswordGenerator``` A service that generates random passwords.
- ```IRetryDelayCalculator``` A service that calculates retry delay with (truncated) binary exponential back-off.
- ```IStringEncryptionService``` A service that can be used to simply encrypt/decrypt texts.
### ```Fluxera.Extensions.DataManagement```
This extension contains an infrastructure for inserting seed data into databases.
### ```Fluxera.Extensions.DependencyInjection```
This extension contains several additions to the dependency injection extension.
- Decorator
- Add decorators to services.
- Named Services
- Add named service implementations.
- Lazy Services
- Add ```Lazy``` as open generic sevice type. Any service will be resolved lazily from it.
- Object Accessor
- Provides a way to access object instances from the ```IServiceCollection``` while still configuring services.
### ```Fluxera.Extensions.Http```
This extension provides a way to register named ```HttpClient``` services and several custom ```DelegatingHandler``` implementations.
```C#
public interface ITestHttpClientService : IHttpClientService
{
Task GetSomethingAsync();
}
public class TestHttpClientService : HttpClientServiceBase, ITestHttpClientService
{
///
public TestHttpClientService(string name, HttpClient httpClient, RemoteService options)
: base(name, httpClient, options)
{
}
public async Task GetSomethingAsync()
{
HttpResponseMessage response = await this.HttpClient.GetAsync("/");
return await response.Content.ReadAsStringAsync();
}
}
services.AddHttpClientService(
context => new TestHttpClientService(context.Name, context.HttpClient, context.Options));
```
### ```Fluxera.Extensions.Localization```
This extension contains several extension methods ```IStringLocalizer``` service.
### ```Fluxera.Extensions.OData```
This extension provides a way to register named ```ODataClient``` services using ```Simple.OData.Client```.
```C#
public interface ITestODataClientService : IODataClientService
{
}
public class TestODataClientService : ODataClientServiceBase, ITestODataClientService
{
///
public TestODataClientService(string name, string collectionName, IODataClient oDataClient, RemoteService options)
: base(name, collectionName, oDataClient, options)
{
}
}
services.AddODataClientService("People",
context => new TestODataClientService(context.Name, context.CollectionName, context.ODataClient, context.Options));
```
### ```Fluxera.Extensions.Validation```
This extension provides an abstraction over validation frameworks. Any one framework can
be used together with other ones. The validation results will merged by the extension.
At the moment ```System.ComponentModel.Annotations``` and ```FluentValidation``` is supported.
One can configure the validators to use like this:
```C#
IServiceCollection services = new ServiceCollection();
services.AddValidation(builder =>
{
builder
.AddDataAnnotations()
.AddFluentValidation(registration =>
{
registration.AddValidator();
});
});
```
## References
[Steve Collins](https://stevetalkscode.co.uk/)
- [Named Dependencies Part 1](https://stevetalkscode.co.uk/named-dependencies-part-1)
- [Named Dependencies Part 2](https://stevetalkscode.co.uk/named-dependencies-part-2)