using System;
using Castle.Windsor;
using Castle.MicroKernel.Registration;
using System.Reflection;
using Castle.MicroKernel.Resolvers.SpecializedResolvers;
namespace Windsor
{
class MainClass
{
public static void Main (string[] args)
{
var container = new WindsorContainer ();
container.Register (Component.For (typeof(IIface<, >)).ImplementedBy (typeof(HandlerImpl<, >)));
//container.Register (Component.For (typeof(IIface<, >)).ImplementedBy(typeof(Impl2)));
container.Kernel.Resolver.AddSubResolver (new ArrayResolver (container.Kernel));
var normal = container.ResolveAll<IIface<Impl2, Stub>> ();
var ex = container.ResolveAll<IIface<Impl1, Stub>> ();
//var qwe = new HandlerImpl<Impl1, Stub> ();
Console.WriteLine("Hello World!");
}
}
public class Base {}
public class Stub {}
public interface AdditionalIface
{
}
public interface IIface<T1, T2> where T1 : Base where T2 : class
{
T1 Command { get; set; }
}
public class HandlerImpl<T1, T2> : IIface<T1, T2> where T1 : Base, AdditionalIface where T2 : class
{
public T1 Command { get; set; }
}
public class Impl1 : Base
{
}
public class Impl2 : Base, AdditionalIface
{
}
}
So, now if i do smth like:
var normal = container.ResolveAll<IIface<Impl2, Stub>> (); // this works ok
var ex = container.ResolveAll<IIface<Impl1, Stub>> (); // this throws exception abou not fullfilled constraints
// instead i want it just show no resolved implementations
Is there any way to make this work as I want it to?