My favorites | Sign in
Project Logo
                
Search
for
Updated Apr 04, 2009 by tyler2325
002__Injection  
How to Inject Values into Attributes

Injection

Automatic Injection

In order to automatically inject values into a variable 3 things need to happen.

  1. The variable to inject must be public
  2. The variable to inject needs to be marked for injection with [Inject('injectorId')]
  3. The class must be introspected by Mainline

example

package com.mydomain.myapp
{
	import com.tylerbeck.mainline.Mainline;

	public class MyClass
	{
		[Inject('injectorId')]
		public var myVar:Object;
		
		public function MyClass( )
		{
			super();
			Mainline.introspect( this );
		}
	}
}

Programmatic Injection

Mainline also allows you to get the contents of an injector manually. To do this you can use the following syntax:

myVar = Mainline.getInjectorValue('injectorId')


Comment by Dars...@gmail.com, Apr 18, 2009

Why the requirement for an 'injectorId'? Surely a lot of the time Inject? why be good enough?


Sign in to add a comment
Hosted by Google Code