我正在编写一个加载YAML文件的PHP CLI应用程序.尝试在xDebug会话中执行此操作时:
if (file_exists(__DIR__ . '/../../foo/bar')
{
/* ... */
}
Run Code Online (Sandbox Code Playgroud)
__DIR__永诺是xdebug:这将导致百达至false从file_exists().
有什么工作吗?
有没有可能在构造函数中识别我的服务的哪个方法被调用?
我的例子:我想构建一个可以暂停的服务SetPauseService(true),这样他在暂停时就不会做任何工作.我不想在每个方法中检查暂停标志,所以我试图在构造函数中存档它.我的问题是,用户必须SetPauseService(false)在服务暂停时调用再次激活服务.
[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()
{
/* ... */
}
}
Run Code Online (Sandbox Code Playgroud)