WCF
複数のクライアントが接続しているサービスがあります。
私たちのサービスは、インスタンスごとのサービスになるように設定されています。サービスは、その作業を行うために別のインスタンス オブジェクトにアクセスする必要があります。必要なインスタンスは wcf サービスではなく、必要なインスタンスをシングルトンにしたくありません。
サービスが私が作成したオブジェクトである場合は、対話する必要があるインスタンス オブジェクトを渡すだけです。ただし、これは wcf サービスであるため、wcf によって作成されます。
サービスの作成をフックして、使用するデータ/インターフェイスを渡す方法、または作成後にサービスへのポインターを取得して、必要なインスタンスを渡す方法を教えてください。
[ServiceContract]
public interface IMyService
{
[OperationContract(IsOneWay = true)]
void DoSomethingCool();
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
class MyService : IMyService
{
private IHelper helper;
void DoSomethingCool()
{
// How do I pass an instance of helper to MyService so I can use it here???
helper.HelperMethod();
}
}