I'm using Windsor and I've got a spot where I'm calling
container.Resolve() directly. Yes, bad, I know and I'm working on
fixing that but I ran into a problem and I'm wondering if I'm doing
something wrong.
I have some code that does the basic:
container.Resolve<TheType>();
But there's some spots where I need to pass extra data to the ctor and
that data is not a dependency that is registered in Windsor. I do
that via:
container.Resolve<OtherType>(new { arg1 = "Yeah"});
As part of my work to remove direct access to the Windsor container, I
created a factory interface that basically did those two types of
calls:
public interface IViewFactory
{
T CreateView<T>() where T : IView;
T CreateView<T>(object argumentsAsAnonymousType) where T : IView;
}
And I registered this interface with the TypedFactoryFacility (very
cool, BTW!) My calls to:
factory.CreateView<TheType>();
work fine. But if I try and use the other method (with anonymous type
to pass additional constructor data):
factory.CreateView<OtherType>(new { arg1 = "Yeah"});
I get an exception from Windsor saying the non-optional dependency
arg1 could not be resolved.
Should this work? I'm using Windsor 2.5.1 from NuGet. Thanks.
---
Patrick Steele
http://weblogs.asp.net/psteele
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.