Part of Lamar's mission is to be a much more performant replacement for the venerable StructureMap IoC container library.
As such, it supports much of the syntax of StructureMap's IContainer
interface and Registry DSL syntax for service registrations with the hopes that Lamar can be a near drop in replacement in many systems that use StructureMap today.
Because most new server side development in .Net today is targeting ASP.Net Core, 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 as shown in the samples below:
Lamar's Container
class subclasses another class in Lamar called Scope
that you probably won't interact with much directly:
public class Container : Scope, IContainer, INestedContainer, IServiceScopeFactory, IServiceScope,
ISupportRequiredService
Scope
itself directly implements several other ASP.Net Core related interfaces:
public class Scope : IServiceContext
IServiceScope, ISupportRequiredService, IServiceScopeFactory are all ASP.Net Core DI abstractions.
Lamar as IoC Container Documentation
- Software Design Concepts
- Bootstrapping a Container
- Integration with ASP.Net Core
- Integration with Blazor
- Registration
- Service Lifetimes
- Resolving Services
- Generic Types
- Decorators
- Lamar Diagnostics
- Auto Wiring
- Building Objects with Lambdas
- Injecting Services at Runtime
- Lamar and IDisposable
- Lazy Resolution
- Nested Containers (Per Request/Transaction)
- Setter Injection
- Working with Enumerable Types