What is the difference between AddLamar() and UseLamar()?
See original GitHub issueI expected both of these tests to pass but the first one doesn’t. What am I missing?
[Fact]
public void ServiceCollection_AddLamar()
{
var services = new ServiceCollection();
services.AddLamar();
var provider = services.BuildServiceProvider();
using (var scope = provider.CreateScope())
{
Assert.IsType<Container>(scope);
}
}
[Fact]
public void HostBuilder_UseLamar()
{
var hostBuilder = new HostBuilder();
hostBuilder.UseLamar();
var host = hostBuilder.Build();
using (var scope = host.Services.CreateScope())
{
Assert.IsType<Container>(scope);
}
}
I can live with using HostBuilder
but just don’t understand why the difference.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Integration with ASP.Net Core - Lamar
Net Core, you also need to call the UseLamar() method as shown below: ... you'll use the same ConfigureContainer() albeit with a different...
Read more >Lamar - Getting Started
To get started, just add Lamar to your project through Nuget. Most of the time you ... Net Core, you also need to...
Read more >Lamar 1.0: Faster, modernized successor to StructureMap
Net Core style registrations natively; There is no semantic difference between Add() and Use() like there was in StructureMap.
Read more >StructureMap
There is no semantic difference between Add () and Use() like there was in StructureMap. Last one in wins. Just like ASP.Net Core...
Read more >How to use Lamar in ASP.Net Core
Take advantage of Lamar, the speedy successor to StructureMap, to inject dependencies in ASP.Net Core.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@RyanThomas73 You’re treading into “I take pull requests” territory here. I’m happy to take a PR if you want this, but nobody else is asking for this feature.
@jeremydmiller The point of being able to use the the
BuildServiceProvider()
is that the requirement of passing it into a lamar container constructor is misleading from an isolation / decoupling standpoint. Lamar’s service registry implements IServiceCollection but this is misleading, as the implementation can only be correctly used when combined with the lamar container.