is there any possibility to recognize within the constructor, which method of my service is called?
My example:
I want to build a service which can be paused via SetPauseService(true), so that he won’t do any work while paused. I don’t want to check the pause flag in every method, so I’m trying to archive this in the constructor.
My problem is, that the user has to call SetPauseService(false) while the service is paused to activate the service again.
[ServiceContract]
public class MyService
{
private static bool isPaused;
public MyService()
{
if (/*<Pseudo>*/ InvokedMethod != "SetPauseService" /*</Pseudo>*/)
{
if (isPaused)
{
throw new Exception("Cannot be executed, service is paused!");
}
}
}
[OperationContract]
public void SetPauseService(bool status)
{
isPaused = status;
}
[OperationContract]
public void DoWork()
{
/* ... */
}
}
I believe what you are looking for can be found in:
This will expose the called operation.
Is this what you needed ?