我有一个跨层传输的业务层对象,Widget。我希望它在不同的层中公开一组不同的属性。以下是编译器读取注释时的样子:
//bl.dll
public abstract class Widget
{
//repo only
internal virtual Ppty_A {get;set;} //internal to implementation assembly of repo
//repo and service only
internal virtual Ppty_B {get;set;} //internal to implementation assemblies of repo/svc
//everyone inlcuding presentation
public virtual Ppty_C {get;set;}
}
public interface IWidgetService
{ ... } }
public interface IWidgetRepo
{ ... }
public class SimpleWidgetService : IWidgetService
{ ... }
//dal.dll
using bl;
public WidgetRepo
{ ... }
//presentation.dll
using bl;
public WidgetController
{
public WidgetController(IWidgetService ...)
...
}
我的想法是这样做(我还没有测试过,它只解决了一半的问题):
//bl.dll
public abstract class Widget
{
//repo only simply can't be defined in the abstraction -- can't see you => no contract
//repo and service only has to be public?
public virtual Ppty_B {get;set;}
//at least public is public...
public virtual Ppty_C {get;set;}
}
//dal.dll
using bl;
public SQLWidget : Widget //Or actually DALBLWidget -- see below?
{
//repo only
internal ...
internal ...
//the rest
...
}
我应该只创建另一个抽象小部件(有一个 DAL-BL 小部件和一个 BL-UI 小部件)吗?