【发布时间】:2009-04-04 13:40:16
【问题描述】:
我正在尝试为将访问多个不同社交网络 API 的应用程序确定最佳设计。这是一个我还没有确定的界面,因为它感觉不太对劲。我想知道解决这个问题的更好的设计方法...
public interface ISocialNetworkAPI<TApiEntity> where TApiEntity : SocialNetworkEntity
{
List<TApiEntity> GetAllFollowersFor(string networkUserName);
List<TApiEntity> GetAllFriendsFor(string networkUserName);
List<long> GetFollowerIdsFor(long networkUserId);
List<long> GetFollowerIdsFor(string networkUserName);
List<long> GetFriendIdsFor(string networkUser);
TApiEntity GetUser(string networkUserName);
}
我还计划使用 DI 容器根据调用的上下文注入适当的社交网络具体对象。
【问题讨论】:
-
您可能会查看适配器设计模式...每个适配器都将遵循您上面的接口。 MySpaceAPIAdapter、FacebookAPIAdapter...