TryExecute() public method

public TryExecute ( string cmd ) : void
cmd string
return void
        static void Main(string[] args)
        {
            XmlConfigurator.Configure();

            string listenAddress = null;
            string script = null;
            bool help = false;
            var options = new OptionSet
                        {
                            {"listen=", x => listenAddress = x },
                            {"script=", x => script = x },
                            {"h|?|help", x => help = x != null},
                        };

            options.Parse(args);
            if (listenAddress == null || help)
            {
                PrintUsage();
                return;
            }

            var buffers = new InputOutputBuffers();

            Log.Info("Initializing PowerShell");
            var powerShell = new PSWrapper(buffers, () => ExitEvent.Set());

            buffers.RegisterForInCommand((cmd, scope) => powerShell.TryExecute(cmd.TextLine));

            var config = new HttpSelfHostConfiguration(listenAddress);
            config.Services.Insert(typeof(IHttpControllerActivator), 0, new ControllerActivator(buffers));

            config.Routes.MapHttpRoute("session", "session", new { controller = "Session" });
            config.Routes.MapHttpRoute("content", "{contentFile}", new { controller = "Content" });

            var server = new HttpSelfHostServer(config);
            Log.InfoFormat("Staring HTTP listener at {0}", listenAddress);
            server.OpenAsync().Wait();

            if (script != null)
            {
                RunScript(script, powerShell);
            }
            else
            {
                StartInteractivePrompt(buffers);
            }
            Log.InfoFormat("System ready");
            ExitEvent.Wait();
            server.CloseAsync().Wait();

            powerShell.Dispose();
        }
 private static void RunScript(string script, PSWrapper powerShell)
 {
     Log.InfoFormat("Executing script {0}", script);
     powerShell.TryExecute(". " + script);
     powerShell.Exit(0);
 }