New Posts New Posts RSS Feed: How do I understand the [InjectionConstructor] Tag?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

How do I understand the [InjectionConstructor] Tag?

 Post Reply Post Reply
Author
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Topic: How do I understand the [InjectionConstructor] Tag?
    Posted: 02-Aug-2007 at 7:26am
So, trying to understand the syntax, could we say something like this?
 
[InjectionConstructor]
public SalesRepModule([ServiceDependency] workItem rootWorkItem)
{
     _rootWorkItem = rootWorkItem;
}
 
means:
 
Th object builder by passing in the workitem constructs the sales rep object with a dependency on the workitem.
 
Once the object is created and the dependency declared, then the new object has access to the workitem which it uses to add the controller and run it (load method).  Right?
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 01-Aug-2007 at 5:18pm
Hmmm...workitem into module...opposite of what I was thinking.  Must meditate on that.
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 01-Aug-2007 at 4:40pm
This is called "constructor injection".  The [ServiceDependency] attribute causes the object builder to provide the root workitem as a parameter of the constructor.  It is injecting the workitem INTO the SalesRepModule.
 
Bill J
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 01-Aug-2007 at 1:49pm
In the SalesRepModule.cs class there is this constructor:
 
/// <summary>Ctor.</summary>
[InjectionConstructor]
public SalesRepModule([ServiceDependency] WorkItem rootWorkItem) {
_rootWorkItem = rootWorkItem;
}
 
When the Object Builder does its magic, what object is this class being injected into?  In other words, something is going to depend on this module...how do I know what that is?  Am I asking the right question, even?
 
Thanks,
Bill
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down