2011-04-26 4 views
1

에 대해 궁금 해서요 wcf 좀 분해 될 경우에는 IRepository다른 사람들이 Wcf 서비스 계약을 사용할 수 있습니까 (nhibernate asp.net)

2 개의 다른 소스가 동일한 계약을 사용하기 때문에 혼합 : - 1 WCF 에 의해 사용되는 - Asp.net에 의해 다른 Nhibernate

그래서 하나 또는 두 가지 물건을 다른 복제본을 만드는 대신 동일한 계약을 재사용하고 싶었어요.

예제로 더 쉽게 이해할 수 있습니다 ...

[ServiceContract] 
public interface ITutorialService 
{ 
    [OperationContract] 
    void AddTutorial(Tutorial newTutorial); 
    [OperationContract] 
    List<Tutorial> GetTutorials(); 
    [OperationContract] 
    void RemoveTutorial(string id); 

    Tutorial GetTutorialModel(); 
    Tag GetTagModel(); 
    Video GetVideoModel(); 

    IRepository<Tutorial> GetTutorialRepository(); 
    IRepository<Tag> GetTagRepository(); 
    IRepository<Video> GetVideoRepository(); 
} 

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] 
public class TutorialService : ITutorialService 
{ 
    private IRepository<Tutorial> _tutorial; 
    private IRepository<Tag> _tag; 
    private IRepository<Video> _video;...... 

은 짧게 wcf가 잘 작동했는데 Irepository에 [OperationContract]을 추가하지 않았습니까?

답변

1

예 가능합니다. [OperationContract]이없는 메서드는 WCF 작업이 아니지만 원하는대로 들릴 것입니다.

또 다른 접근법은 두 개의 인터페이스를 가지며 하나는 다른 인터페이스로부터 파생되어 하나의 관심사를 가지므로 두 가지 인터페이스를 두 번 정의 할 필요가 없습니다.

+0

@ 브래드 튼 !! 당신은 내 아침에 <3 –

관련 문제