我一直在使用一個外觀設計模式將我需要的所有行政功能組合在一起。接口和外觀設計模式
在我的類庫Company.Infrastructure.Repositories.Administration我:
[Pluggable("Default")]
public class AdminRepository : IAdminRepository
{
#region private members
#endregion
#region protected members
protected Membership _membership;
protected Permissions _permissions;
protected Application _application;
protected Profile _profile;
#endregion
public AdminRepository()
{
_membership = new Membership();
_permissions = new Permissions();
_application = new Application();
_profile = new Profile();
}
protected class Profile
{
public Profile() {}
public void ProfileMethod1(){}
public void ProfileMethod2(){}
}
protected class Membership
{
public Membership() {}
public User GetUser(Guid id)
{
using (var dc = new My_SdbDataContext())
{
var user = dc.aspnet_Users.Where(x => x.UserId == id).FirstOrDefault();
var membership = dc.aspnet_Memberships.Where(x => x.UserId == id).FirstOrDefault();
return Convert.ToEntity(user, membership);
}
}
public User GetUser(string userName)
{
using (var dc = new My_SdbDataContext())
{
var user = dc.aspnet_Users.Where(x => x.UserName == userName).FirstOrDefault();
var membership = dc.aspnet_Memberships.Where(x => x.UserId == user.UserId).FirstOrDefault();
return Convert.ToEntity(user, membership);
}
}
public IEnumerable<User> GetUsers(Guid applicationId)
{
var userList = new List<User>();
using (var dc = new My_SdbDataContext())
{
var users = dc.aspnet_Users.Where(x => x.ApplicationId == applicationId).ToList<aspnet_User>();
userList.AddRange((IEnumerable<User>) (from user in users
let membership = dc.aspnet_Memberships.Where(x => x.UserId == user.UserId).FirstOrDefault()
select Convert.ToEntity(user, membership)));
}
return userList;
}
}
etc...
}
這很適合我的工作。但是,我們已經轉移到DDD模型,並試圖找出如何繼續從WCF服務訪問我的AdminRepository(以前稱爲AdminFactory)。
爲了實現訪問,我已經在我的域邏輯中包含了我的Repository類的接口。但是,我不太清楚如何去創建一個Facade的界面,比如我有的界面(包括子類和全部)。這可能嗎?
我該怎麼做?