.NET 4.5에서 Neo4J 용 데이터 액세스 라이브러리를 모의하려고합니다. 나는 각 명령을 데이터베이스에 정의하기 위해 인터페이스를 사용하고있다.C# 부모 인터페이스의 속성 상속
을 감안할 때 :
public interface IBaseRequest
{
HttpMethod HttpMethod { get; }
string QueryUriSegment { get; }
}
public interface ICreateNode : IBaseRequest
{
void CreateNode();
}
public interface IBaseNodeActions : ICreateNode,ICreateNodeWProperties //...And many others, all inherit from IBaseRequest
{
}
internal class TestImplClass : IBaseNodeActions {
public TestImplClass() {
}
void ICreateNode.CreateNode() {
throw new NotImplementedException();
}
//Only one copy of the HttpMethod and QueryUriSegment are able to be implemented
DataCommands.HttpHelper.HttpMethod IBaseRequest.HttpMethod {
get {
throw new NotImplementedException();
}
}
string IBaseRequest.QueryUriSegment {
get {
throw new NotImplementedException();
}
}
문제가 IBaseRequest에서 상속 각 인터페이스입니다, 나는 그것이 부모 (HttpMethod, QueryUriSegment)를 소유의 각 속성에 대해 구현 된 속성을해야합니다.
이것이 가능합니까? 명시 적 구현을 사용하는 것이 필요하지만 구현 클래스로 푸시하는 방법을 모르는지 알고 있습니다. 여기
내가 내 구현 클래스에서보고 싶은 것입니다 :
public class TestImplClass : IBaseNodeActions{
public TestImplClass() {
}
void ICreateNode.CreateNode() {
throw new NotImplementedException();
}
HttpMethod ICreateNode.HttpMethod {
get {
throw new NotImplementedException();
}
}
string ICreateNode.QueryUriSegment {
get {
throw new NotImplementedException();
}
}
HttpMethod ICreateNodeWProperties.HttpMethod {
get {
throw new NotImplementedException();
}
}
string ICreateNodeWProperties.QueryUriSegment {
get {
throw new NotImplementedException();
}
}
}
주목하라 ICreateNode 대신 IBaseRequest의 ICreateNodeWProperties. 나는 그것을 다르게하는 것에 개방적이지만 모듈화되고 검증 가능한 접근법처럼 보인다.
나는 그것이 의미가 있기를 바랍니다!
나는 당신이 원하는 것을 이해하지 못합니다. 테스트 클래스가 모든 인터페이스를 구현합니까 ??? 그렇다면 호출 할 인터페이스에 따라 속성이 다른 결과를 제공하기를 원하십니까? –
또는 이러한 속성을 여러 번 구현하지 않으려 고합니다. ??? 그렇다면 명시 적으로 속성을 구현하지 마십시오. –