0

レイヤー間を移動するビジネス レイヤー オブジェクト、ウィジェットがあります。さまざまなレイヤーでさまざまなプロパティのセットを公開したいと考えています。コンパイラがコメントを読み取ると、次のようになります。

//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 ウィジェットがある) を作成する必要がありますか?

4

1 に答える 1

1

Widget クラスに、各レイヤーに対応するさまざまなインターフェイスを実装させることができます。

public class Widget : IDataLayerWidget, IBusinessLayerWidget
{
 // Properties
}

public interface IDataLayerWidget
{
   // Properties visible to the DataLayer
}

public interface IBusinessLayerWidget
{
   // Properties visible to the BusinessLayer
}

DataLayer では を使用IDataLayerWidgetし、ビジネス層では を使用しますIBusinessLayerWidget

于 2012-04-15T19:29:20.000 に答える