I have the following classes defined:
public interface IShapeView
{
void DoSomethingWithShape(Shape shape);
}
public interface IShapeView<T> where T : Shape
{
void DoSomethingWithShape(T shape);
}
public class CircleView : IShapeView<Circle>, IShapeView
{
public void DoSomethingWithShape(Circle shape)
{
MessageBox.Show("Circle:" + shape.Radius);
}
void IShapeView.DoSomethingWithShape(Shape shape)
{
DoSomethingWithShape((Circle)shape);
}
}
public class Circle : Shape
{
public Circle()
{
Radius = 1.0;
}
public double Radius { get; set; }
}
And the following registration:
container.Register(Component.For<IShapeView<Circle>>().ImplementedBy<CircleView>());
Is there a method that I can call to resolve a view when I only have the Type of the shape? Or do I need to go to the trouble of using reflection to create the generic type arguments to get the correct type of IShapeView that I want? Looking for something like this:
Type shapeType = typeof(Circle);
IShapeView view = (IShapeView) container.SomeResolveMethod(shapeType, typeof(IShapeView<>));