Injecting with a Method

Mar 21, 2007 at 2:32 PM
Hi!

Trying to figure some stuff out regarding the ObjectBuilder. (Good work btw!)

Can someone please give me an example where it can be useful to use the InjectionMethodAttribute (with associated strategies)? I mean when would I typically have use of this strategy?

Am I thinking incorrectly or could one case be this? I have constructor or property strategies to inject my objects, however one of the objects might have NotPresentBehavior.ReturnNull in which case I need to create it some other way.

Also it would be useful to see a sample of this being used on a method which takes parameters but I have not been able to find one. Can someone please write one?

Cheers,

/Magnus
Mar 22, 2007 at 9:04 PM
Hi Magnus, the MethodExecutionStrategy is scheduled in the post initialization builder stage by default. At this time your already have your object created and the injected properties in place too. So I think you can use this strategy to perform any logic that is not available in the OB pipeline. For example: You could validate your object, you could open a connection, you could open a resource, etc.

I will think an example of how to invoke the method with parameters and I will post it later.

HTH
--------------------
Adrian Alonso
http://adrianalonso.blogspot.com/