

TstValue = BlackRingTester.testValue 'TstValue = "I'm a live BlackRing" TstValue = OrbitTester.testValue 'TstValue = "I'm a live Orbit"ĭim BlackRingTester As BlackRing = CType(TheRunes.Factory(Of BlackRing)(), BlackRing) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Clickĭim OrbitTester As Orbit = CType(TheRunes.Factory(Of Orbit)(), Orbit) It use reflection to get the required type of rune that should be build, by getting the type of rune from the type of "T" passed in the (T as Runes) in the function factory, and used reflection again to invoke the Both of these runes implement an interface "Runes", so both, the orbit and the BlackRing can be referenced as a "Runes". In this code, I did implement 2 type of runes, an Orbit and a BlackRing. Then your rune factory needs to create instance of a class that have a private constructor. In a first time the rune type should not be a class but an interface, so each different runes can be of the same typeĪll your runes class should implement this interface, this way, T can be of the type of the interface a therefore reference any type of runes each rune is a class with a private constructor. If I understand your problem, you want to create a class that will create some runes.

You cannot use a Shared method to create instance.
