SlideShare a Scribd company logo
LightInject for Asp.Net Core
Shawn Vause
Senior Web Applications Engineer @ ZOLL LifeVest
January 10, 2017
Overview
 Inversion of Control
 Out of the Box
 Replacements for Asp.Net Core
 LightInject
 Questions
Inversion of Control
 Mechanism/Technique
 Dependency instances bound at
runtime
 Instances/implementations of
abstractions not known at
compilation time
 Loose coupling of dependencies
 Maintenance/Modification
 Testability
S – Single Responsibility
O – Open/Closed
L – Liskov Substitution
I – Interface Segregation
D – Dependency Injection
SOLID Principles
Out of the Box
Feature IServiceProvider
Constructor Injection +
Framework Provided Services
(MVC, Entity Framework, Identity, etc.)
+
Transient Lifetimes +
Singleton Lifetimes +
Scoped Lifetimes +
Named Type Injections -
Explicit use of resolved constructor parameters -
Registration Fallbacks -
Custom Lifetimes -
Property Injection -
More… -
Replacements for Asp.Net Core
 AutoFac
 Simple Injector
 StructureMap
 LightInject
LightInject
Feature IServiceProvider LightInject
Constructor Injection + +
Framework Provided Services
(MVC, Entity Framework, Identity, etc.)
+ -
Transient Lifetimes + +
Singleton Lifetimes + +
Scoped Lifetimes + +
Named Type Injections - +
Explicit use of resolved
constructor parameters
- +
Registration Fallbacks - +
Custom Lifetimes - +
Property Injection - +
More… - +
LightInject
 Step 1 – project.json
LightInject
 Step 2 – Startup.cs
LightInject
 Step 3
LightInject
 Recommendations
 Strongly consider a project specific to dependency injection activities
 Build extension method classes for registrations
 Out of box strengths in conjunction with full-fledged IOC library (best of both worlds)
 Ex: All the framework registration activities
LightInject
References
 Sample Project
https://github.com/napalm684/ReciPiBookCore
 LightInject
https://github.com/seesharper/LightInject.Microsoft.DependencyInjection
Questions?
Twitter ->
@SuperVause
Blog ->
http://svause.azurewebsites.net/

More Related Content

PDF
Carmen fantasy arr. baldeyrou
PDF
The Pink Panther - Trombone Quartet
PDF
O fantasma da opera
PDF
Tico tico soprano e cifras
PDF
Coronel Souza Aguiar
PDF
Dobrado Janjão
PDF
Comandante narciso
PDF
[Clarinet institute] debussy, claude 1st arabesque
Carmen fantasy arr. baldeyrou
The Pink Panther - Trombone Quartet
O fantasma da opera
Tico tico soprano e cifras
Coronel Souza Aguiar
Dobrado Janjão
Comandante narciso
[Clarinet institute] debussy, claude 1st arabesque

What's hot (14)

PDF
Aqueles Olhos Verdes
PDF
Manual de Perkins del 3144 al 6PF305
PDF
Pout Pourri de Samba Canção
PDF
PDF
Cabelo de fogo - Duda
PDF
Where Eagles Soar - Steven Reineke - Set of Clarinets
PDF
Filme Festival - Hans Koldiz
PDF
Partituradebanda.pagode russo
PDF
Dilermando Reis - Xodó da Baiana
PDF
Gershwin george-rhapsody-blue-rhapsody-blue-1st-clarinet-pdf-38818
PDF
Blue for Brass
PDF
Coronel Bogey(v3)
PDF
Canção do Marinheiro - Cisne Branco
Aqueles Olhos Verdes
Manual de Perkins del 3144 al 6PF305
Pout Pourri de Samba Canção
Cabelo de fogo - Duda
Where Eagles Soar - Steven Reineke - Set of Clarinets
Filme Festival - Hans Koldiz
Partituradebanda.pagode russo
Dilermando Reis - Xodó da Baiana
Gershwin george-rhapsody-blue-rhapsody-blue-1st-clarinet-pdf-38818
Blue for Brass
Coronel Bogey(v3)
Canção do Marinheiro - Cisne Branco
Ad

Similar to LightInject for ASP.Net Core (11)

PPTX
.NET Intro & Dependency Injection Workshop
PPTX
It depends: Loving .NET Core dependency injection or not
PDF
Alex Thissen "It depends: loving .NET Core dependency injection or not"
PPTX
Dependency injection presentation
PPTX
Dependency Injection in .NET
PPTX
Clean Code II - Dependency Injection
PDF
ASP.NET Core Interview Questions PDF By ScholarHat.pdf
PPTX
ASPNET-Core-Powering-the-Future-of-Web-Development (1).pptx
PPTX
I gotta dependency on dependency injection
PPTX
Dependency Injection
PPTX
IoC and Mapper in C#
.NET Intro & Dependency Injection Workshop
It depends: Loving .NET Core dependency injection or not
Alex Thissen "It depends: loving .NET Core dependency injection or not"
Dependency injection presentation
Dependency Injection in .NET
Clean Code II - Dependency Injection
ASP.NET Core Interview Questions PDF By ScholarHat.pdf
ASPNET-Core-Powering-the-Future-of-Web-Development (1).pptx
I gotta dependency on dependency injection
Dependency Injection
IoC and Mapper in C#
Ad

Recently uploaded (20)

PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Introduction to Artificial Intelligence
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPT
Introduction Database Management System for Course Database
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
medical staffing services at VALiNTRY
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
System and Network Administraation Chapter 3
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
L1 - Introduction to python Backend.pptx
PPTX
assetexplorer- product-overview - presentation
Odoo Companies in India – Driving Business Transformation.pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Introduction to Artificial Intelligence
Design an Analysis of Algorithms I-SECS-1021-03
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Introduction Database Management System for Course Database
VVF-Customer-Presentation2025-Ver1.9.pptx
Reimagine Home Health with the Power of Agentic AI​
CHAPTER 2 - PM Management and IT Context
medical staffing services at VALiNTRY
2025 Textile ERP Trends: SAP, Odoo & Oracle
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Internet Downloader Manager (IDM) Crack 6.42 Build 41
System and Network Administraation Chapter 3
Upgrade and Innovation Strategies for SAP ERP Customers
L1 - Introduction to python Backend.pptx
assetexplorer- product-overview - presentation

LightInject for ASP.Net Core

Editor's Notes

  • #4: Mechanism/Technique Helps us accomplish SOLID principle of dependency injection
  • #7: We get all the robustness we are used to in an IOC library It is a lot like Unity which per Jeff Fritz that project/team has disbanded at MS Work on-going in open source to try and port but seems to have stalled
  • #11: Recommendations Strongly consider a project specific to dependency injection activities Build extension method classes for registrations **BOTH KEEPS STARTUP.CS SIZE DOWN** Out of box strengths in conjunction with full-fledged IOC library (best of both worlds) Ex: All the framework registration activities **EXAMPLES TYPICALLY WORK WITH OUT OF BOX IOC, LEVERAGE THAT REMEMBERING LightInject etc BOLT ON TO OUT OF BOX**
  • #12: We have all seen the above registration which would give us the ability to inject a dbcontext to a consumer DbContext is inherently difficult to test or mock out Repositories introduced to get around this/make life easier Generic Repositories reduce duplication of “standard” database code What if my application uses multiple database I don’t want to couple the repository just to RecipesDb in this case. I can use named registrations to have multiple registrations for a single type and tell the repository for a given registration what database to use that is registered in the container.