Thanks, Ayende, I got this to work.
Being the beginner I am, it seems that the container providing multiple
instances of an implementation forces my injected class to determine which
element in the array is appropriate to use.
For example, the constructor of the class looks like
Public ImportController (IPostInbound[] inboundProcessor){
_inboundProcessor = inboundProcessor;
}
For each method which requires an instance of the array, I have to look
through the array like,
if (typeRequiredByMethod == _inboundProcessor[0].GetType())
return _inboundProcessor[0];
else .
Is this the correct approach?
Thanks for the help, Lars
From: [email protected]
[mailto:[email protected]] On Behalf Of Ayende Rahien
Sent: Wednesday, March 04, 2009 12:01 PM
To: [email protected]
Subject: Re: Error Keys (components with specific keys)
Add the ArrayResolver to the kernel.
container.Kernel.Resolver.AddSubResolver(new ArrayResolver());
On Wed, Mar 4, 2009 at 11:22 AM, Lars Zeb <[email protected]> wrote:
I am new to Castle, trying to configure the container programmatically
rather than with XML.
I have an interface which has two implementations.
container.AddComponent("importDB", typeof (IPostInboundToDatabase),
typeof (PostAddresses));
container.AddComponent("importFC", typeof (IPostInboundToDatabase),
typeof (PostFC));
In the constructor into which I want to inject both implementations, I
have tried two ways to define the signature:
public Import(IDictionary<string, IPostInboundToDatabase>
inboundDB) {...}
public Import(IPostInboundToDatabase[] inboundDB) {...}
Both signatures resulted in the following error:
Keys (components with specific keys)
- inboundDB which was not registered.
If this can be done, what is the proper way to do it? I have to use
programmatic, not XML, configuration.
Thanks for any help, Lars
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---