I use a WCF service and wonder if I can use the OperationContract methods for the caller and for the service. Therefore I'd like to know the best way to say if the code is running in the application or in the service.
Like this:
[ServiceContract]
public interface IService
{
[OperationContract]
bool ServiceMethod(string param);
}
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single,
InstanceContextMode = InstanceContextMode.Single, UseSynchronizationContext=false)]
public class Service : IService
{
bool ServiceMethod(string param)
{
if(!isInWcfService) //How to do this?
{
//Call this ServiceMethod in WCF Service
}
else
{
//Do the work
}
}
}
Since the calling program and the service knows this class, I think it might be easier if both just have to call this one method and it decides itself if it has to forward the call to the service or can just do to work.
Thank you!