-
Notifications
You must be signed in to change notification settings - Fork 33
Dependency injection
The following IoC integration packages are available:
Install package IbanNet.DependencyInjection.ServiceProvider
Add IbanNet services with defaults:
services.AddIbanNet();
Or add IbanNet services with configuration:
services
.AddIbanNet(opts => opts
.UseRegistryProvider(new MyCustomRegistryProvider())
.WithRule<MyCustomRule>()
);
Install package IbanNet.DependencyInjection.Autofac
Register IbanNet services with defaults:
container.RegisterIbanNet();
Or register IbanNet services with configuration:
container
.RegisterIbanNet(opts => opts
.UseRegistryProvider(new MyCustomRegistryProvider())
.WithRule<MyCustomRule>()
);
Both integrations provide the following services:
The validator is designed to be used as a singleton, to reduce initialization time required for each individual validation. When the validator is first used, it loads the country rules once and for each country code that a validation is executed for, the rules are prepared and cached. This allows higher throughput of validations which is especially beneficial in web API's.
Avoid creating an instance of
IbanValidator
upon each individual validation. If you need further proof, look at the benchmark results.