Professional Documents
Culture Documents
IoC and Mapper in C#
IoC and Mapper in C#
SOLID Principles
Dependency Inversion, IoC, Dependency Injection
Pros and cons of Dependency Injection
Apply DI frameworks into MVC project
AutoMapper – What, Why and How
SOLID Principles
• Single Responsibility
• Open/Closed
• Liskov Substitution
• Interface Segregation
• Dependency Inversion
Dependencies
Lower application layers
External services
Other components
User Interface
Depends on
Which Depends On
Which Depends On
Database
Example Code
Dependencies Inversion (Principle)
Dependency
Service Locator Event Delegate
Injection
Example Code
Why Dependency Injection
• Loose coupling code
• Testability
• Clear dependency
• Separate of concern
• Easy to change
Why NOT Dependency
Injection
• Hard to learn
• Hard to debug
• Object created before needed
• More layer => More complexity
Simple DI Container
IoC in Action
Unity
Ninject
Structure Map
What
An “object to object”
mapper
Why
Remove the boring
mapping code
When
Entity to DTO
Entity to Data Contact
Entity to View Model
Before and after
Mapper in Action