How do I Map a Model?

There are several methods available on the injector for mapping your Model classes for injection into your framework actors. In addition, these methods can be used for injecting virtually ANY class into your classes.

To map an existing instance for injection that will be treated as a singleton, use the following syntax:

injector.mapValue(MyModelClass, myModelClassInstance)

To map a new instance of a class for each injection, use the following syntax:

injector.mapClass(MyModelClass, MyModelClass)

Additionally, this can be used to map interfaces for injection, with a concrete class that implements the interface being injected:

injector.mapClass(IMyModelClass, MyModelClass)

To map a singleton instance of an interface or class, use the following syntax:

injector.mapSingleton(MyModelClass, MyModelClass)

It is important to note that when referring to a singleton above, it is not a Singleton. It is not enforced outside of the Context as a Singleton. The injector simply insures that one and only one instance of the class will be injected. This is vital for Model classes that are handling your application data model.