Questions tagged [lamar]

Lamar is a new OSS library written in C# that is a new IoC container meant to replace the venerable, but increasingly creaky StructureMap library.

Lamar was purposely designed and built to maximize compliance with the underlying IoC behavior assumed by ASP.Net Core. To reduce friction in Lamar usage, Lamar directly implements the core ASP.Net Core abstractions for dependency injection.

36 questions
1
vote
1 answer

Injecting configuration values in ASP .NET Core 2.1

As with others, I disagree with injecting IOptions into every service that may need it, and looked for other options. My goal was to inject the values needed by the service, and nothing more. I came up with the following, which is working and…
0
votes
2 answers

How to use Lamar with .Net 6 console application

Sorry I don't have any example code. I'm simply trying to find an example of how to use Lamar with a new .Net 6 console application and not finding anything on google. The application is basically just a task runner app. It takes in a command line…
geoff swartz
  • 5,437
  • 11
  • 51
  • 75
0
votes
0 answers

Some services are registered as Singleton which causes an error

I am working on an ASP.NET Core 5 project. I am using Lamar for dependency Injections. Scan(scanner => { scanner.TheCallingAssembly(); scanner.WithDefaultConventions(); …
manora
  • 23
  • 7
0
votes
0 answers

Microsoft.Dependency.Injection similar to Lamar For and Use function

I would like to ask about Microsoft.Extensions.DependencyInjection library for IoC implementation. Is there a way to do a similar function for the Lamar library function like services.For().Use() in…
Alvin Quezon
  • 1,089
  • 3
  • 11
  • 29
0
votes
0 answers

Lamar Dependencies on RunTime

I am using creating a library that enables developer to add services at runtime. I am not sure if I'm doing this right but below is my code that I made for this: Test Class public class Test : ITest { public void Run() { string…
Alvin Quezon
  • 1,089
  • 3
  • 11
  • 29
0
votes
0 answers

Lamar Service Cannot Build Registered Instance

Lamar failed to create instance when trying execute my Service. I'm not sure if I've done it right it should create an instance because I add it in the registry and it fails when trying to execute via Action. See code below for reference: Below…
Alvin Quezon
  • 1,089
  • 3
  • 11
  • 29
0
votes
0 answers

How to set Lamar to create generic implementation for non-generic ILogger interface

Microsoft's Built-in DI Container can't create a non-generic ILogger instance as described in this post. How can I configure the DI Container (I use Lamar) to create generic ILogger where T is the requesting class - just like described here: Inject…
0
votes
1 answer

Lamar register service with interface having multiple parameters

Brief Intro - we are using Lamar as IoC container. I am looking for some help to understand how to register a service which implements interfaces with multiple parameters. my interface => interface IEntityCompareService { IList
Anshul
  • 55
  • 2
  • 9
0
votes
1 answer

Conversion to Lamar - Registration - What's the equivalent of this code that uses StructureMap?

I'm migrating an ASP.NET application to .NET5 and have come across the following code that uses StructureMap... For().AlwaysUnique().Singleton().HttpContextScoped().Add() We are using Lamar in the new application; what's the…
inthegarden
  • 267
  • 1
  • 11
0
votes
0 answers

Lamar with MediatR registering constructor dependencies, is there a better way?

I am using Lamar and i have added a load of dependencies which work in my controllers. When i try to use a handler from MediarR i am having to explicitly set the Ctor dependancies like so: serviceRegistry …
Hawkzey
  • 1,088
  • 1
  • 11
  • 21
0
votes
1 answer

Using the Lamar DI container, how do you build objects with a lambda given a type?

Lamar provides the following syntax for building objects with a lambda: serviceRegistry.For().Use(x => { ... }); This would allow you to resolve ISomeType which would execute the registered delegate: var someType =…
Derek Greer
  • 15,454
  • 5
  • 45
  • 52
0
votes
1 answer

Lamar AddScoped not working as expected net core webapi

I have netcore webapi project and i'm using Lamar for DI. I have a service MyContextService which i register as scoped public class LifetimeRegistry : ServiceRegistry { public LifetimeRegistry() { …
tayab
  • 130
  • 2
  • 11
0
votes
2 answers

How can I auto resolve concrete types in Lamar?

The following documentation is not working for multiple reasons: https://jasperfx.github.io/lamar/documentation/ioc/resolving/requesting-a-concrete-type/ First the documentation states that you can new up a Container with a default constructor which…
Gary Brunton
  • 1,840
  • 1
  • 22
  • 33
0
votes
1 answer

Lamar AddInstances with ServiceRegistry

I have a dotnet core website setup with Lamar, I have the following method in Startup.cs public void ConfigureContainer(ServiceRegistry services) { ... } I want to use AddInstances() as described in the documents at…
Phil
  • 1,609
  • 12
  • 24
0
votes
1 answer

Can we resolve an implementation of an interface that uses other implementations of an interface using Lamar in .NET Core 3?

I'm using .NET Core 3.0 and have the following classes public class DataProviderA: IDataProvider { } public class DataProviderB: IDataProvider { } public class DataProviderCombined: IDataProvider { public DataProviderCombined(IDataProvider…
SamIAm
  • 2,241
  • 6
  • 32
  • 51