Skip to content

Instantly share code, notes, and snippets.

@otaviolarrosa
Created June 20, 2019 18:08
Show Gist options
  • Save otaviolarrosa/ec1aa129d71b2842285b55efba8f7fef to your computer and use it in GitHub Desktop.
Save otaviolarrosa/ec1aa129d71b2842285b55efba8f7fef to your computer and use it in GitHub Desktop.
UnityContainer implemented in Vb.Net
Imports Unity
Module Module1
Public Interface IMyFirstInterface
Sub Test()
End Interface
Public Class MyFirstClass
Implements IMyFirstInterface
Private ReadOnly secondInterface As IMySecondInterface
Sub New(ByVal secondInterface As IMySecondInterface)
Me.secondInterface = secondInterface
End Sub
Public Sub Test() Implements IMyFirstInterface.Test
Console.WriteLine("Here, In Test Method.")
secondInterface.Test2
End Sub
End Class
Public Interface IMySecondInterface
Sub Test2()
End Interface
Public Class MySecondClass
Implements IMySecondInterface
Public Sub Test2() Implements IMySecondInterface.Test2
Console.WriteLine("Here, In Test2 Method.")
End Sub
End Class
Sub Main()
Dim container As IUnityContainer
container = New UnityContainer
container.RegisterType(Of IMyFirstInterface, MyFirstClass)
container.RegisterType(Of IMySecondInterface, MySecondClass)
Dim minhaClasse As IMyFirstInterface
minhaClasse = container.Resolve(Of IMyFirstInterface)
minhaClasse.Test
End Sub
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment