Inject a Class object as a static variable
Can I make this happen at application startup?:
[Inject] public static var pageClass:Class;
Comments are currently closed for this discussion. You can start a new one.
Can I make this happen at application startup?:
[Inject] public static var pageClass:Class;
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Joel Hooks on 05 May, 2010 03:11 PM
not really. One, I don't think you are going to have luck with the base class injection.
That would work.
3 Posted by Alan Shaw on 05 May, 2010 03:22 PM
Are you saying that it's not possible to inject a variable of type Class (a Class object not an instance)?
Support Staff 4 Posted by Joel Hooks on 05 May, 2010 03:39 PM
It is possible, assuming you only ever have a single mapping for type Class.
Support Staff 5 Posted by Shaun Smith on 05 May, 2010 04:32 PM
Hi Alan,
Injecting a class (object) into another object is fine and shouldn't give you any issues. Injecting into a class (I'm looking at that "static" keyword) is another story..
Using a DI container to set static (global) properties, whilst technically possible, is conceptually strange and practically dangerous. Besides, why use mutable statics when you have a DI container at your disposal?
6 Posted by Alan Shaw on 05 May, 2010 05:16 PM
It appears that I can do this bit of configuration more simply without using injection. Guess I went overboard there. Thanks!
Stray closed this discussion on 11 Feb, 2011 11:42 PM.