public WorkflowClient(IWorkContext context, NamedValueSet settings)
        {
            // default configuration
            const SvcId svc    = SvcId.GridSwitch;
            EnvId       env    = EnvHelper.ParseEnvName(BuildConst.BuildEnv);
            Guid        nodeId = Guid.NewGuid();

            // custom configuration
            if (settings != null)
            {
                // environment
                env = (EnvId)settings.GetValue(WFPropName.EnvId, (int)env);
            }
            env = EnvHelper.CheckEnv(env);
            // derived configuration
            string hosts = null;
            int    port  = EnvHelper.SvcPort(env, svc);

            if (settings != null)
            {
                port   = settings.GetValue(WFPropName.Port, port);
                hosts  = settings.GetValue(WFPropName.Hosts, hosts);
                nodeId = settings.GetValue(WFPropName.NodeId, nodeId);
            }
            string svcName = EnvHelper.SvcPrefix(svc);

            string[] serviceAddrs = EnvHelper.GetServiceAddrs(env, svc, false);
            if (hosts != null)
            {
                serviceAddrs = hosts.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            }
            ServiceAddress resolvedServer = V111Helpers.ResolveServer(context.Logger, svcName, new ServiceAddresses(WcfConst.AllProtocols, serviceAddrs, port),
                                                                      new[] { typeof(IDiscoverV111).FullName });
            // initialise worksteps
            List <IWorkstep> worksteps = GridWorksteps.Create();

            foreach (IWorkstep workstep in worksteps)
            {
                workstep.Initialise(context);
                workstep.EnableGrid(GridLevel.Client, nodeId, resolvedServer.Port, resolvedServer.Host);
            }
            Clients = worksteps.ToArray();
        }