특정 서비스 인스턴스 및 작업의 컨텍스트 내에서 실행중인 경우 현재 실행중인 서비스 인스턴스에 대한 액세스 권한을 얻으려면 어떻게해야합니까?현재 컨텍스트에서 WCF 서비스 인스턴스에 대한 액세스 권한을 얻으려면 어떻게해야합니까?
OperationContext.Current
하지만 실제 서비스를 참조하는 속성을 찾을 수 없습니다 : 서비스 인스턴스가 특정 공통 기본 클래스 또는 인터페이스와 내가 찾을 수있는 기존의 상황에 유일한 경로에서 상속하지 않는 것은 인스턴스 자체를 사용해야 만 내가 알고 있어야하는 작업으로 캐스팅하고 작업을 수행 할 수 있습니다.
내가이 작업을 수행하는 이유를 조사하지 않고 (관련이 없음) 찾고있는 참조를 찾을 수있는 방법이 있는지 알려주십시오.
편집 :
[ServiceContract]
public interface IInventory
{
[OperationContract]
List<DealInfo> ListDeals(DealQueryOptions options);
}
// This is the object I will need access to the current instance of
public class Inventory : ServiceBase<Inventory>, IInventory
{
public List<DealInfo> ListDeals(DealQueryOptions options)
{
var obj = new Whatever(); // see below
}
}
public class Whatever
{
public Whatever()
{
// how do I get access to the service instance here?
// assume that in this context we are not allowed to
// pass the service instance to this class; this class
// must automatically discover the instance itself.
}
}
죄송이 IIRC에 대한 속성이 있어야합니다, 당신은 더 정확하게 당신이 찾고있는 것을 조금 설명 할 수 있을까? OperationContext.Current는 필요한 모든 것을 한 가지 방법으로 제공해야합니다. –
예를 들어 질문을 업데이트했습니다. –
"What"클래스의 소스 코드를 제어하지는 않지만 여전히 인스턴스 데이터를 전달하려고합니다. 내가 맞습니까? –