2017-04-20 1 views
-1

IDataContextA를 사용하는 경우 IStoreable 또는 smth와 같은 T에 더 많은 제한을 추가 할 수 있습니다. 하지만 그 한계점 하나만 있다면 여전히 차이가 있습니까?일반 인터페이스 제한 T

public interface IDataContextA 
{ 
    IBusinessModel<T> GetModel<T>() where T : IBusinessObject; 
} 

public interface IDataContextB 
{ 
    IBusinessModel<IBusinessObject> GetModel<IBusinessObject>(); 
} 
+0

IBusinessObject, IStoreable,' –

+1

을 'IDataContextB.GetModel()에서'IBusinessObject'는 제한이없는 일반적인 매개 변수입니다. 아마 당신이 의도 한 것이 아닙니다. – Lee

+0

Lee가 맞습니다. 타이 – Olli

답변

0

당신이 뭔가를 시도 할 수 있습니다 :`IBusinessModel 을 getModel () T : 내가 그래, 당신은 인터페이스 제약 쌓을 수, 제대로 이해하면

public interface IGenericContext<T> 
{ 
    IBusinessModel<T> GetModel<T>() where T : IBusinessObject, IStoreable; 
} 

public interface IDataContextB : IGenericContext<IBusinessObject> 
{ 

}