通知の処理に使用するシンプルなクラスがあります。複数のバインディングのためのNinjectコンストラクタ引数
public class ApplePushNotifier : IApplePushNotifier
{
public ApplePushNotifier(
ILog log,
IMessageRepository messageRepository,
IUserRepository userRepository,
CloudStorageAccount account,
string certPath)
{
// yadda
}
// yadda
}
そしてローカル証明書ファイル検索するための文字列引数が含ま結合シンプルNinject、:
kernel.Bind<IApplePushNotifier>().To<ApplePushNotifier>()
.WithConstructorArgument("certPath",
System.Web.Hosting.HostingEnvironment.MapPath("~/bin/apns_universal.p12"));
これは明らかに、かなり基本的なもの、すべてが素晴らしい仕事をしています。
kernel.Bind<IMessageProcessor>().To<ApplePushNotifier>()
.WithConstructorArgument("certPath",
System.Web.Hosting.HostingEnvironment.MapPath("~/bin/apns_universal.p12"));
そして、それはあまりにも動作しますが、重複コンストラクタ引数が私に巣箱を与える:私はこのようなバインディング秒を追加することができます
public class ApplePushNotifier : IApplePushNotifier, IMessageProcessor
:今、私は、そのクラスへの第2のインタフェースを追加しました。私はこのような明示的な自己結合の追加を試みた:
kernel.Bind<ApplePushNotifier>().To<ApplePushNotifier>()
.WithConstructorArgument("certPath",
System.Web.Hosting.HostingEnvironment.MapPath("~/bin/apns_universal.p12"));
kernel.Bind<IApplePushNotifier>().To<ApplePushNotifier>();
kernel.Bind<IMessageProcessor>().To<ApplePushNotifier>();
しかし、無サイコロを - 私は古い「該当バインディングが用意されていません」というエラーが表示されます。
コンストラクタの引数を独自のバインド可能な型に昇格するか、またはクラスが実装するすべてのインターフェイスで繰り返さずに、このようなコンストラクタ引数を指定する方法はありますか?
ほとんどあまりにも簡単!私はこれを処理する簡単な方法がなければならないことを知っていました、ありがとう! – superstator