This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "defaultAssembly": "DependencyInjectionVBPart02", | |
| "components": [ | |
| { | |
| "type": "DependencyInjectionVBPart02.Child, DependencyInjectionVBPart02", | |
| "services": [ | |
| { | |
| "type": "DependencyInjectionVBPart02.Interfaces.IChild, DependencyInjectionVBPart02.Interfaces" | |
| } | |
| ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Private Sub InitializeContainer() | |
| Dim configurationBuilder = New ConfigurationBuilder() | |
| configurationBuilder.SetBasePath(Environment.CurrentDirectory) | |
| configurationBuilder.AddJsonFile("Autofac.json") | |
| Dim configurationModule As New ConfigurationModule(configurationBuilder.Build()) | |
| Dim containerBuilder = New ContainerBuilder() | |
| containerBuilder.RegisterModule(configurationModule) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sub Main() | |
| InitializeContainer() | |
| Dim child = _container.Resolve(Of IChild) | |
| child.Drink() | |
| Console.ReadLine() | |
| End Sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Private Sub InitializeContainer() | |
| Dim builder As New ContainerBuilder() | |
| builder.RegisterType(Of Milk.DrinkService).As(Of IDrinkService)() | |
| builder.RegisterType(Of Child).As(Of IChild)() | |
| _container = builder.Build() | |
| End Sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Public Class Child | |
| Implements IChild | |
| Private ReadOnly _drinkService As IDrinkService | |
| Public Sub New(drinkService As IDrinkService) | |
| _drinkService = drinkService | |
| End Sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Public Interface IChild | |
| Sub Drink() | |
| End Interface |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sub Main() | |
| InitializeContainer() | |
| Dim drinkService = _container.Resolve(Of IDrinkService) | |
| Dim child As New Child(drinkService) | |
| child.Drink() | |
| Console.ReadLine() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Imports Autofac | |
| Imports Autofac.Core | |
| Imports DependencyInjectionVBPart02.Interfaces | |
| Module MainModule | |
| Private _container As Container | |
| Private Sub InitializeContainer() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Imports DependencyInjectionVBPart02.Interfaces | |
| Public Class Child | |
| Private ReadOnly _drinkService As IDrinkService | |
| Public Sub New(drinkService As IDrinkService) | |
| _drinkService = drinkService | |
| End Sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Imports DependencyInjectionVBPart02.Interfaces | |
| Public Class DrinkService | |
| Implements IDrinkService | |
| Public Sub Drink() Implements IDrinkService.Drink | |
| Console.WriteLine("Drink a glass of orange juice") | |
| End Sub |
NewerOlder