A library that extends the Microsoft.Extensions.* libraries with custom functionality and also provices custom extensions.
This extension contains Option
classes for configuring a remote distributed cache server and
several useful extension methods for the IDistributedCache
service.
This extension contains several custom services:
IDateTimeOffsetProvider
A service that provides mockable access to staticDateTimeOffset
.IDateTimeProvider
A service that provides mockable access to staticDateTime
.IGuidGenerator
A service to generateGuid
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.
This extension contains an infrastructure for inserting seed data into databases.
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<T>
as open generic sevice type. Any service will be resolved lazily from it.
- Add
- Object Accessor
- Provides a way to access object instances from the
IServiceCollection
while still configuring services.
- Provides a way to access object instances from the
This extension provides a way to register named HttpClient
services and several custom DelegatingHandler
implementations.
public interface ITestHttpClientService : IHttpClientService
{
Task<string> GetSomethingAsync();
}
public class TestHttpClientService : HttpClientServiceBase, ITestHttpClientService
{
/// <inheritdoc />
public TestHttpClientService(string name, HttpClient httpClient, RemoteService options)
: base(name, httpClient, options)
{
}
public async Task<string> GetSomethingAsync()
{
HttpResponseMessage response = await this.HttpClient.GetAsync("/");
return await response.Content.ReadAsStringAsync();
}
}
services.AddHttpClientService<ITestHttpClientService, TestHttpClientService>(
context => new TestHttpClientService(context.Name, context.HttpClient, context.Options));
This extension contains several extension methods IStringLocalizer
service.
This extension provides a way to register named ODataClient
services using Simple.OData.Client
.
public interface ITestODataClientService : IODataClientService
{
}
public class TestODataClientService : ODataClientServiceBase<Person, string>, ITestODataClientService
{
/// <inheritdoc />
public TestODataClientService(string name, string collectionName, IODataClient oDataClient, RemoteService options)
: base(name, collectionName, oDataClient, options)
{
}
}
services.AddODataClientService<ITestODataClientService, TestODataClientService>("People",
context => new TestODataClientService(context.Name, context.CollectionName, context.ODataClient, context.Options));
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:
IServiceCollection services = new ServiceCollection();
services.AddValidation(builder =>
{
builder
.AddDataAnnotations()
.AddFluentValidation(registration =>
{
registration.AddValidator<PersonValidator>();
});
});