0
WCFオートファクトコンテナ(IContainer)は、WCF以外のプロジェクトクラスでどのように使用できますか?WCF Autofac Containerをn-tierアーキテクチャの別のプロジェクトレベルで使用する
Autofac to Serviceプロジェクト(下記のサンプル)を追加することは唯一の解決方法であり、これを実現する他の優雅な方法です。
サービスをパラメータとして渡すことができない
助けてください。
WCFサービスプロジェクト(Autofac WCFを使用します)
public class DiscountWCFService
{
public IDiscountService service {get; set;}
}
サービスプロジェクト
public class DiscountService : IDiscountService
{
public IDiscountRepository repository {get; set;}
}
public static class DiscountExtension
{
public static IDiscountProcessor GetProcessor(this Discount discount)
{
if(discount.Type=1) return TypeAProcessor();
if(discount.Type=2) return TypeBProcessor();
return null;
}
}
public class TypeAProcessor : IDiscountProcessor
{
// Is it possible to use Autofac?
// E.G. IService fooService = AutofacContainer.Resolve<IFooService>
}
public class TypeBProcessor : IDiscountProcessor
{
}
エンティティプロジェクト
public class Discount
{
}