Basic example

Create an object with an injectable field and use DependencyInjector to set the field value.

Example3.Basic example

Import sodaware.blitzmax_injection

' Create a type to be injected.
Type SomeObject
    Field name:String
End Type

' Create a type to inject into.
Type MyType
    Field someValue:SomeObject    { injectable }

    Method New()
        ' Register this object as having injectable fields.
    End Method
End Type

' Create the object to be injected.
Local toInject:SomeObject = New SomeObject = "To inject"

' Create the object that will be injected.
Local target:MyType = new MyType
' => target.someValue = Null

' Run the injection.
DependencyInjector.injectAll(target, [toInject])

' Check the field got set.
' => "To inject"