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
1
vote
2 answers

dependency injection - convert ninject di to lightinject di

How do I convert the following Ninject DI to the equivalent for LightInject DI? I'm having issues with getting to the right syntax. Database.SetInitializer(new MigrateDatabaseToLatestVersion
1
vote
2 answers

Lightinject Equivalent of Ninject's WhenInjectedInto

Does LightInject have an equivalent method of Ninject's WhenInjectedInto()? (Ninject - Contextual Binding) For example, I have two classes, let's say MicrosoftOffice and LibreOffice, that implement an interface IOfficeSuite. Two other classes,…
peflorencio
  • 2,284
  • 2
  • 32
  • 40
1
vote
1 answer

Register Multiple Interface Implementation In LightInject IoC

I have an interface with two implementations. public interface ILogger { void Log(string message); } public class FileLogger : ILogger { public void Log(string message) {} } public class SQLiteLogger : ILogger { public void Log(string…
Ask Too Much
  • 627
  • 4
  • 19
1
vote
1 answer

Lightinject and xUnit InjectData

I'm trying to setup xUnit with the LightInject framework but cannot get the xUnit InlineDataAttribute to work. The following test code doesn't work: public static void Configure(IServiceContainer container) { container.Register();…
henrikh
  • 31
  • 6
1
vote
1 answer

LightInject IoC container resolve type by a custom method?

Is it possible in LightInject IoC to resolve a type based on some custom method? eg the resolver would call a method like this public interface IMyType {} public class MyEvenType : IMyType {} public class MyOddType : IMyType {} public static int…
JK.
  • 21,477
  • 35
  • 135
  • 214
1
vote
1 answer

Lightinject with Web API - How can I get the HttpRequestMessage?

How can I get the current HttpRequestMessage when using Lightinject with Web API? In Simple Injector, for example, I have the following extension method on the container: var msg = container.GetCurrentHttpRequestMessage() But I couldn't find a…
Yaron Levi
  • 12,535
  • 16
  • 69
  • 118
1
vote
0 answers

Lightinject - Build ServiceContainer from IServiceDescriptor for MVC 6 application

I'm working on a new MVC application using the new MS frameworks and am having trouble trying to convert an IServiceDescriptor to a LightInject IServiceContainer... The reason why I'm going about this is because in the new MS MVC framework we…
1
vote
2 answers

Dependency injection - named dependencies

I'm dealing with one problem. Imagine this example situation. I have one module e.g. UserModule with injected IUserRepository. IUserRepository can have more implementations e.g. IUserRepositorySql and IUserRepositoryDefault. public class UserModule…
y0j0
  • 3,369
  • 5
  • 31
  • 52
0
votes
1 answer

.net framework- how to create IServiceProvider to get already registered service instance using IServiceProvider?

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…
0
votes
1 answer

LightInject equivalent lifetime in .netcore DI container

Migrating from 'LightInject' to .netcore DI container. What are the .netcore DI container equivalents of below LightInject related registrations? a. container.RegisterConstructorDependency((factory, parameterInfo) => new Bar()); b.…
0
votes
0 answers

Lightinject - how to safely begin new scope outsice composition root?

I have Windows service accepting some messages. I use LightInject for DI. The service writes into database via dbContext every time any message comes. Thus I need to limit dbContext's lifetime to handling of that message and dispose it once the…
Qerts
  • 935
  • 1
  • 15
  • 29
0
votes
0 answers

light inject - unit testing

I have an c# interface with multiple implementations & each implementation is taking various dependencies object in its constructor. In order to achieve DI using LightInjector on web api project, Im registering a 'Func' like below & its working as…
0
votes
0 answers

How to register an open generic that accepts parameters in LightInject?

I have the following generic class, which depends on IBar: public class Foo : IFoo { public Foo(IBar bar, int value) { } ... } I would ideally register it using something like this in LightInject: container.Register
Gyum Fox
  • 3,287
  • 2
  • 41
  • 71
0
votes
1 answer

LightInject - Register multiple implementation of same interface

Using Lightinjector DI framework how to register multiple implementation of same interface? how to mention the same interface on constructor and ask for its different implementation? container.Register(); …
0
votes
0 answers

ASP.NET MVC site occasionally rendering in random RESX language - Possible DI Issue?

I have an ASP.NET 4.8 MVC app that has numerous languages. These are RESX files which are defined in their own class library. That class library is then being injected into the MVC app using LightInject as the Dependancy Injection library. I am…
dalcam
  • 1,027
  • 11
  • 28