Manos.Tool.Driver.RunServer C# (CSharp) Method

RunServer() public method

public RunServer ( IList args ) : void
args IList
return void
        public void RunServer(IList<string> args)
        {
            string port = null;
            string securePort = null;
            string certFile = null;
            string keyFile = null;
            string user = null;
            string assembly = null;
            string ipaddress = null;
            string browse = null;
            string docroot = null;

            var p = new OptionSet () {
                { "p|port=", v => port = v },
                { "P|secureport=", v => securePort = v },
                { "c|certfile=", v => certFile = v },
                { "k|keyfile=", v => keyFile = v },
                { "u|user=", v => user = v },
                { "a|assembly=", v=> assembly = v},
                { "l|listen=", v => ipaddress = v },
                { "b|browse=", v => browse = v },
                { "d|docroot=", v => docroot = v}
            };
            args = p.Parse(args);

            ServerCommand cmd = new ServerCommand (Environment, args);

            if(assembly != null)
            {
                cmd.ApplicationAssembly = assembly;
            }

            if (port != null) {
                int pt;
                if (!Int32.TryParse (port, out pt))
                    throw new ArgumentException ("Port value is not an integer.");
                if (pt <= 0)
                    throw new ArgumentOutOfRangeException ("port", "Port must be a positive integer.");
                cmd.Port = pt;
            }

            if (securePort != null) {
                if (certFile == null)
                    throw new ArgumentException ("Certificate file required for TLS.");
                if (keyFile == null)
                    throw new ArgumentException ("Certificate private key required for TLS.");
                int pt;
                if (!Int32.TryParse (securePort, out pt))
                    throw new ArgumentException ("Secure port value is not an integer.");
                if (pt <= 0)
                    throw new ArgumentOutOfRangeException ("secureport", "Secure port must be a positive integer.");
                cmd.SecurePort = pt;
                cmd.CertificateFile = certFile;
                cmd.KeyFile = keyFile;
            }

            if (user != null)
                cmd.User = user;

            if (ipaddress != null)
                cmd.IPAddress = ipaddress;

            if (docroot != null)
                cmd.DocumentRoot = docroot;

            if (browse != null)
                cmd.Browse = browse;

            cmd.Run ();
        }

Usage Example

示例#1
0
        private static int Server(IList <string> args)
        {
            Driver d = new Driver();


            try {
                d.RunServer(args);
            } catch (Exception e) {
                Console.WriteLine("error while serving application:");
                Console.WriteLine(e);
                return(1);
            }

            return(0);
        }
All Usage Examples Of Manos.Tool.Driver::RunServer