LightInject | An ultra lightweight IoC container
kandi X-RAY | LightInject Summary
kandi X-RAY | LightInject Summary
An ultra lightweight IoC container
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of LightInject
LightInject Key Features
LightInject Examples and Code Snippets
Community Discussions
Trending Discussions on LightInject
QUESTION
On .NET Framework 4.6.2 application, where there is no built-in DI container we are using LightInject DI Container to object initialization but don't know how to create 'IServiceProvider' Object in Main() so the other class implementations can get the already registered instance of service via IServiceProvider
without using new
keyword.
How to create IServiceProvider
object? in .net framework 4.6.2 application
ANSWER
Answered 2022-Jan-07 at 11:09In general, injecting an IServiceProvider
(or any abstraction that gives access to an unbound set of dependencies is a bad idea, because it can lead to the Service Locator anti-pattern. A discussion on this anti-pattern can be found here.
A Service Locator is something that only exists outside the Composition Root. Your BackgroundService1
, however, might be part of the Composition Root, which might injecting a DI Container -or an abstraction there over- a feasible solution. Note that you should strive keeping all business logic out of the Composition Root. This ensures that BackgroundService1
purely functions as a mechanical peace of code that delegates the operation to classes that run the actual business logic.
Though, when operating inside the Composition Root, there is typically no need to use an abstraction over your DI Container, such as an IServiceProvider
. The Composition Root already has intrinsic knowledge over all application's dependencies, including your DI Container.
This means that you can inject LightInject's ServiceContainer
directly into the constructor of BackgroundService1
; there is no need for an IServiceProvider
.
If, however, you insist in using the IServiceProvider
abstraction, you can create an IServiceProvider
implementation that wraps ServiceContainer
and forwards its GetService
method to the wrapped ServiceContainer
. This wrapper class can than be registered in the ServiceContainer
.
QUESTION
I am using Umbraco 8.4 version and my website is running on the azure app service. I have cloned the existing website and database and published it on another azure app service. When I open the website, I am getting the below error.
...ANSWER
Answered 2021-Sep-16 at 19:03According to your logs, your problem looks like a caching issue and your v8 umbraco website can't get the data from NuCache.
Regenerating the cache data might solve your problem.
I don't know much about NuCache but here is the Umbraco documentation for caching and here is a blog post about NuCache and how to explore it.
QUESTION
I am trying to Register IHttpClientFactory in Full Framework 4.7 (not core). I am using IoC container (LightInject)
Problem, that I do not have direct access to implementation of internal class DefaultHttpClientFactory https://github.com/dotnet/runtime/blob/master/src/libraries/Microsoft.Extensions.Http/src/DefaultHttpClientFactory.cs This class is not visible because it is not public. I found solution as 3rd party implementation - https://github.com/uhaciogullari/HttpClientFactoryLite , bit it uses its own interface.
Is it possible to use interface IHttpClientFactory with IoC for Full Framework(not .net core)?
In case it is possible , what class can i use as implementation for IHttpClientFactory during registration for IoC?
...ANSWER
Answered 2020-Dec-03 at 09:16As it was suggested in this github issue you can use this:
QUESTION
I'm trying to refactoring MVC after core migration to 3.1; I converted Startup like this (LightInject):
...ANSWER
Answered 2020-Jul-15 at 18:27I had the same problems running LightInject on .NET CORE MVC 3.1.
I managed to get working versions of the code.
Need to add ConfigureContainer()*
QUESTION
It was very handy with Autofac on dependency injection.
Recently I changed project where lightinject and unitycontainer uses. Here I am able to register a list of services with a name, but I'm unable to resolve by a name.
I tried to get it as IEnumerable
. I'm getting all, but not the name I registered. So I'm unable to distinguish them.
What am I missing here?
...ANSWER
Answered 2020-Jul-09 at 23:43https://www.tutorialsteacher.com/ioc/property-injection-using-unity-container see the section Named Mapping
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install LightInject
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page