I've been looking at this for a couple hours now. I think I must be
missing something obvious.
My scenario is that I am trying to encapsulate a generic collection.
Why can't I do that? What is fundamentally different about List<T>? I
think the code will speak for itself, but I'm happy to provide more
info if you like.
Code follows sig. Please enlighten me!
Thanks,
--Stuart
using System.Collections.Generic;
using Castle.Windsor;
using NUnit.Framework;
namespace Tests
{
[TestFixture]
public class SoConfusedTest
{
[Test]
public void ThisWorks()
{
var container = new WindsorContainer();
container.AddComponent("componentA",
typeof(DependsUponAGenericClass<>));
container.AddComponent("componentB",
typeof(SomeGenericClass<>));
var foo =
container.Resolve<DependsUponAGenericClass<string>>();
}
[Test]
public void ThisDoesNot()
{
var container = new WindsorContainer();
container.AddComponent("componentA",
typeof(DependsUponGenericList<>));
container.AddComponent("componentB", typeof(List<>));
var foo =
container.Resolve<DependsUponGenericList<string>>(); //
throws HandlerException
}
public class SomeGenericClass<T>
{ }
public class DependsUponAGenericClass<T>
{
public DependsUponAGenericClass(SomeGenericClass<T>
dependency)
{ }
}
public class DependsUponGenericList<T>
{
public DependsUponGenericList(List<T> dependency)
{ }
}
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---