-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Evgeniy Goroshkin edited this page Apr 6, 2018
·
2 revisions
This container allow you decrease code dependancies in your business logic.
Instead of writing
Local presenter:=New Presenter( New Game,New LocalMetrica,New OutputLogger )
you can write
Local presenter:=Di.Resolve<Presenter>()
and work with Presenter w/o thinking about Logger, Metrica, etc.
Yes - you must setup container before using it.
But when you make changes in setup you achive these changes in all places where container is used.
So, you can bind special realization for debug.
Or bind special mock/stub for testing build.
How to bind
Di.Bind( Lambda:IDataProvider()
Print "create develop DataProvider"
Return New TestDataProvider
End )
In example above we bind IDataProvider type with TestDataProvider realization.
If you have a function returned type of realization, you can specify generic type
to bind with needed interface.
For example:
' return concrete type
Function GetProductionProvider:DataProvider()
Return New DataProvider
End
' bind that concrete type with interface type
' specifying it as generic type of Bind
Di.Bind<IDataProvider>( GetProductionProvider )