Override constructor arguments

4 views
Skip to first unread message

davidhall

unread,
Dec 3, 2008, 7:21:56 PM12/3/08
to structuremap-users
Hi, is it possible to override constructor arguments at runtime?

If have the following Constructor definition for one of my windows
forms:

WorksheetEntryForm(IWorksheetService wsService, ITaskService
taskService, int worksheetID)

This allows the form to get the default worksheet for today when the
worksheetID is 0, or get the provided worksheetID

I'm using the following in my bootstrapper class:

ForRequestedType<WorksheetEntryForm>
().TheDefault.Is.OfConcreteType
<WorksheetEntryForm>().WithCtorArg
("worksheetID").EqualTo(0);

Is it possible to override the Constructor Argument injection, so that
my worksheet search form can use StructureMap to constuct an instance
of WorksheetEntryForm but provide it with a worksheetID?

Also, is it possible to change the worksheetID to a nullable int, and
still use constructor injection?

Thanks,
David

Reply all
Reply to author
Forward
0 new messages