please create an issue in donjon
On Sun, Feb 22, 2009 at 11:50 AM, christianacca <
[email protected]> wrote:
>
> This is quite surprising - I get a NotImplementException thrown when
> trying to Resolve<T> a component that has a dependency on a dictionary
> (either a Hasedtable or a generic Dictionary<T,U>), when the
> dependency is *supplied at runtime*.
>
> I found a workaround - to declare the dependency as System.Object, but
> this an ugly hack.
>
> Can someone please point out that I am wrong and indicate what the
> appropriate way of supplying a dictionary to a component at runtime.
> Here is the test that reproduces the problem (and the workaround).
>
> [Test]
> public void ShouldBeAbleToSupplyDictionaryAsARuntimeParameter()
> {
> var container = new WindsorContainer();
> container.Register(Component.For<ClassTakingDictionary>());
>
> var someDictionary = new Hashtable();
>
> //The call to resolve throws NotImplementedException
> var s = container.Resolve<ClassTakingDictionary>(new
> { SomeDictionary = someDictionary });
> Assert.That(s, Is.Not.Null);
> }
>
>
> [Test]
> public void Workaround()
> {
> var container = new WindsorContainer();
> container.Register(Component.For<ClassTakingDictionary>());
>
> var someDictionary = new Hashtable();
>
> var s = container.Resolve<ClassTakingDictionary>(new
> { SomeDictionaryToBeInjected = someDictionary });
> Assert.That(s, Is.Not.Null);
> }
>
> public class ClassTakingDictionary
> {
> public IDictionary SomeDictionary { get; set; }
>
> public object SomeDictionaryToBeInjected
> {
> set { SomeDictionary = value as IDictionary; }
> }
> }
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---