dimanche 4 janvier 2015

The type '' cannot be used as type parameter '' in the generic type or method ''. There is no implicit reference conversion from '' to ''

I am trying to implement some generic in View - Controller classes. My "framework looks like that:


Controllers:



public interface IController<TView> where TView : IView
{
// some generic fields / methods definitions
}

public abstract class BaseController<TView> : IController<TView> where TView : IView
{
// some generic fields / methods implementation
}

public interface IConcreteController
{
// some specific fields / methods definition
}

public class ConcreteController<TView> : BaseController<TView>, IConcreteController where TView : IView
{
// specific implementation
}


Views:



public abstract class IView : UserControl // MARKER
{
}

public class BaseView<TController> : IView where TController : IController<IView>
{
// some generic fields / methods implementation
}

public abstract class IConcreteView : BaseView<IConcreteController>
{
// some specyfic fields methods definition
}

public class ConcreteView : IConcreteView
{
// some specific fields methods implementation
}


But I get an error:



The type 'IConcreteController' cannot be used as type parameter 'TController' in the generic type or method 'BaseView<TController>'. There is no implicit reference conversion from 'IConcreteController' to 'IController<GenericTest.IView>'.



What am I doing wrong ?


Aucun commentaire:

Enregistrer un commentaire