Questions tagged [light-inject]

An ultra lightweight single file Inversion of Control container for the .Net framework.

An ultra lightweight single file Inversion of Control container for the .Net framework. Use attributes to control injected dependencies. LightInject has full support for the new Windows Runtime making it a perfect choice for Windows Store Apps. Implement cross cutting concerns using the AOP capabilities of LightInject.

LightInject provides two distribution models via NuGet

96 questions
2
votes
1 answer

LightInject a database context in MVC

I'm starting to use LightInject in my MVC application, but I'm a bit confused as to how to implement an instance of a DB Context class. I know I can just inject it via a constructor... but what's the point of LightInject if I have to do this. Also,…
binks
  • 1,001
  • 2
  • 10
  • 26
2
votes
2 answers

How configure LightInject in ASP.NET MVC?

I use SimpleInjector in mvc with this code public static class SimpleInjectorInitializer { public static void Initialize() { var container = new Container(); InitializeContainer(container); …
2
votes
1 answer

Why does LightInject use an ImmutableHashTree to store registrations, instead of a simple Dictionary?

I'm looking at several IoC contains in order to choose one to use in my work, and taking a look at LightInject's codebase I came across something I don't understand... In ServiceContainer's GetInstance(Type serviceType, string serviceName) method,…
Sebastian Nemeth
  • 5,505
  • 4
  • 26
  • 36
1
vote
0 answers

.Net Core, LightInject: How to set up DI via properties

Can't set up dependency injection via properties in a class... I googled everything and looked through all the documentation, so I couldn't find anything how to configure on .net core mvc... Help me please HomeController.cs public class…
Nikita
  • 64
  • 10
1
vote
0 answers

.NET Core, DI LightInject: How to inject a dependency in a Static class?

Please help me sort it out.. ;) How to inject a dependency in a static class? I want to inject Mapper into a static class. I read the documentation and google about LightInject and did not find how to implement it .. Or is there a better solution…
1
vote
1 answer

How to inject IServiceContainer when using LighInject?

I am using LightInject and now I need to know how to resolve a type myself. I've tried to use IServiceContainer, but when I inject this interface into my class I get an error saying that is an unresolved dependency. The thing I want te solve is…
Martijn
  • 24,441
  • 60
  • 174
  • 261
1
vote
0 answers

How can I inject an instance into the current scope?

I would like to do something like the following: public class LightInjectTests { [Fact] public void CanInjectItemIntoScope() { var container = new ServiceContainer(); container.Register(new…
Doug Wilson
  • 4,185
  • 3
  • 30
  • 35
1
vote
1 answer

With LightInject, how can I pass arguments to child dependencies without registering a bunch of factories?

In the code below, I am trying to inject a ViewModel into a View, while the ViewModel requires a Model to wrap and another service that is in the container. The Model is not registered as it is not really a "service". How do I: a) not have to…
burton
  • 421
  • 4
  • 13
1
vote
1 answer

LightInject - How to Register Multiple Interfaces to a Single Service?

How do I register a service that implements 4 interfaces? For example: class Foo : IFoo, IBar, IApp, ISee { ... } I was hoping for something like this: container.Register(); But it appears this signature is for passing…
Kabua
  • 889
  • 8
  • 19
1
vote
0 answers

Issue in LightInject when getting service instance

I have integrated Light Inject in web api project. I am able to register service successfully in application_start in global.asax. I am using filter which needs to be registered as well in application_start in global.asax. Filter constructor have…
karuna
  • 53
  • 1
  • 1
  • 6
1
vote
1 answer

C# LightInject - How to replace an instance in a contain with another

Suppose I have ClassA and ClassB inherit from IClass. Now I have a LightInject container and register an instance of ClassA as ClassA classA = new ClassA(); Helpers.Container.RegisterInstance(typeof(IClass), classA, "Class"); Now I want to replace…
Ben
  • 957
  • 1
  • 11
  • 37
1
vote
1 answer

LightInject - Derived interfaces leads to multiple instances

In my application I handle lots of ViewModels that get registered inside a LightInject Container via several Interfaces. Some of those Interfaces are derived from other for UnitTesting purposes. When resolving multiple ViewModels with the same…
Mohnkuchenzentrale
  • 5,745
  • 4
  • 30
  • 41
1
vote
0 answers

How do I enable property injection for filters with LightInject?

I have an authentication filter that I want to inject with the authentication source. I'm using light inject and I have EnableAnnotatedPropertyInjection() enabled on the container, [Inject] above the property of the filter, and the type of he…
QueueHammer
  • 10,515
  • 12
  • 67
  • 91
1
vote
2 answers

How to use FluentValidation with LightInject in asp.net web-api project

I'm trying to inject a service using the IoC container into a Validation class. See the example below: [Validator(typeof(UserPayloadValidator))] public class UserPayload { public int UserId { get; set; } } public class UserPayloadValidator :…
Bogdan
  • 5,368
  • 9
  • 43
  • 62
1
vote
2 answers

Nuget fails to add lightinject 4.0.6 to portable class library

I'm trying to use lightinject for xamarin application. Common code is inside separate portable class library. This project is configured for TargetFrameWorkProfile Profile78. When I'm adding lightinject 4.0.6 following error appears: Attempting to…