カスタム コンテキストに応じて、別のプロバイダーを返そうとしています。以下を考えると
public interface IProvider
{
    string WhoAreYou();
}
そして2つのプロバイダー
namespace ProviderOne
{
    public class Implementation : IProvider
    {
        public string WhoAreYou()
        {
            return "Provider One";
        }
    }
}
namespace ProviderTwo
{
    public class Implementation : IProvider
    {
        public string WhoAreYou()
        {
            return "Provider Two";
        }
    }
}
そして、次のようなコンテキスト
public class CallContext
{
    public string SomeValue{ get; set; }
    public int AnotherValue { get; set; }
}
私のバインディングは次のようになります
        CallContext context1 = new CallContext()
        {
            SomeValue = "one",
            AnotherValue = 1
        };
        Bind<IProvider>().To<ProviderOne.Implementation>().WithMetadata("callcontext", context1);
        CallContext context2 = new CallContext()
        {
            SomeValue = "two",
            AnotherValue = 2
        };
        Bind<IProvider>().To<ProviderOne.Implementation>().WithMetadata("callcontext", context2);
遅くなりましたが、ここまでは正しいと確信しており、アイデアがありません。
私の問題は、それらのバインディングに到達することです。いろいろな方法を試しました
        var test1 = kernel.Get<IProvider>(b => b.Get<CallContext>("callcontext") == context1);
        //var test1 = kernel.Get<IProvider>(m => m.Has("callcontext") && m.Get<CallContext>("callcontext").Equals(context1));
        //var test1 = kernel.Get<IProvider>(m => m.Get<CallContext>("callcontext").Equals(context1));
        //var test1 = kernel.Get<IProvider>().Equals(context1);
しかし、それらは機能しません。せいぜい「バインドなし」エラーが発生し、最悪の場合、エラーが発生するだけです。私が見落としている簡単な何かがあるに違いない、または単に気づいていない.
ありがとうございました