public override TaskResult Start(TaskExecutionNode node)
        {
            var task = (RunAssemblyTask)node.RemoteTask;

            _contextAssembly = LoadContextAssembly(task);
            if (_contextAssembly == null)
            {
                return(TaskResult.Error);
            }

            var result = VersionCompatibilityChecker.Check(_contextAssembly);

            if (!result.Success)
            {
                Server.TaskExplain(task, result.Explanation);
                Server.TaskError(task, result.ErrorMessage);

                return(TaskResult.Error);
            }

            _listener = new PerAssemblyRunListener(Server, task);

            _runner   = new DefaultRunner(_listener, RunOptions.Default);
            _runScope = GetRunScope(_runner);

            return(TaskResult.Success);
        }
    public override TaskResult Start(TaskExecutionNode node)
    {
      var task = (RunAssemblyTask) node.RemoteTask;

      _contextAssembly = LoadContextAssembly(task);
      if (_contextAssembly == null)
      {
        return TaskResult.Error;
      }

      var result = VersionCompatibilityChecker.Check(_contextAssembly);
      if (!result.Success)
      {
        Server.TaskExplain(task, result.Explanation);
        Server.TaskError(task, result.ErrorMessage);

        return TaskResult.Error;
      }

      _listener = new PerAssemblyRunListener(Server, task);

      _runner = new DefaultRunner(_listener, RunOptions.Default);
      _runScope = GetRunScope(_runner);

      return TaskResult.Success;
    }
    static RunScope GetRunScope(DefaultRunner runner)
    {
      var scope = new RunScope();

      var runnerType = runner.GetType();

      var startRun = runnerType.GetMethod("StartRun", new[]{typeof(Assembly)});
      if (startRun != null)
      {
        scope.StartRun = asm => startRun.Invoke(runner, new object[] { asm });
      }

      var endRun = runnerType.GetMethod("EndRun", new[] {typeof(Assembly)});
      if (endRun != null)
      {
        scope.EndRun = asm => endRun.Invoke(runner, new object[] { asm });
      }

      return scope;
    }
        static RunScope GetRunScope(ISpecificationRunner runner)
        {
            var scope = new RunScope();

            var runnerType = runner.GetType();

            var startRun = runnerType.GetMethod("StartRun", new[] { typeof(Assembly) });

            if (startRun != null)
            {
                scope.StartRun = asm => startRun.Invoke(runner, new object[] { asm });
            }

            var endRun = runnerType.GetMethod("EndRun", new[] { typeof(Assembly) });

            if (endRun != null)
            {
                scope.EndRun = asm => endRun.Invoke(runner, new object[] { asm });
            }

            return(scope);
        }