예제 #1
0
            public override int run(string[] args)
            {
                List <string> argSeq = new List <string>(args);
                const string  prefix = "IceBox.Service.";

                Ice.Properties properties            = communicator().getProperties();
                Dictionary <string, string> services = properties.getPropertiesForPrefix(prefix);

                foreach (KeyValuePair <string, string> pair in services)
                {
                    string name = pair.Key.Substring(prefix.Length);
                    for (int i = 0; i < argSeq.Count; ++i)
                    {
                        if (argSeq[i].StartsWith("--" + name, StringComparison.CurrentCulture))
                        {
                            argSeq.RemoveAt(i);
                            i--;
                        }
                    }
                }

                foreach (string s in argSeq)
                {
                    if (s.Equals("-h") || s.Equals("--help"))
                    {
                        usage();
                        return(0);
                    }
                    else if (s.Equals("-v") || s.Equals("--version"))
                    {
                        Console.Out.WriteLine(Ice.Util.stringVersion());
                        return(0);
                    }
                    else
                    {
                        Console.Error.WriteLine("Server: unknown option `" + s + "'");
                        usage();
                        return(1);
                    }
                }

                ServiceManagerI serviceManagerImpl = new ServiceManagerI(communicator(), args);

                return(serviceManagerImpl.run());
            }
예제 #2
0
파일: Server.cs 프로젝트: bholl/zeroc-ice
            public override int run(string[] args)
            {
                for(int i = 0; i < args.Length; ++i)
                {
                if(args[i].Equals("-h") || args[i].Equals("--help"))
                {
                    usage();
                    return 0;
                }
                else if(!args[i].StartsWith("--", StringComparison.CurrentCulture))
                {
                    Console.Error.WriteLine("Server: unknown option `" + args[i] + "'");
                    usage();
                    return 1;
                }
                }

                ServiceManagerI serviceManagerImpl = new ServiceManagerI(communicator(), args);
                return serviceManagerImpl.run();
            }
예제 #3
0
        private static int run(Ice.Communicator communicator, string[] args)
        {
            const string prefix = "IceBox.Service.";

            Ice.Properties properties            = communicator.getProperties();
            Dictionary <string, string> services = properties.getPropertiesForPrefix(prefix);

            var argSeq = new List <string>(args);

            foreach (KeyValuePair <string, string> pair in services)
            {
                string name = pair.Key.Substring(prefix.Length);
                argSeq.RemoveAll(v => v.StartsWith("--" + name));
            }

            foreach (string arg in args)
            {
                if (arg.Equals("-h") || arg.Equals("--help"))
                {
                    usage();
                    return(0);
                }
                else if (arg.Equals("-v") || arg.Equals("--version"))
                {
                    Console.Out.WriteLine(Ice.Util.stringVersion());
                    return(0);
                }
                else
                {
                    Console.Error.WriteLine("IceBox.Server: unknown option `" + arg + "'");
                    usage();
                    return(1);
                }
            }

            ServiceManagerI serviceManagerImpl = new ServiceManagerI(communicator, args);

            return(serviceManagerImpl.run());
        }
예제 #4
0
파일: Server.cs 프로젝트: joshmoore/ice
        public override int run(string[] args)
        {
            List<String> argSeq = new List<String>(args);
            const String prefix = "IceBox.Service.";
            Ice.Properties properties = communicator().getProperties();
            Dictionary<string, string> services = properties.getPropertiesForPrefix(prefix);
            foreach(KeyValuePair<string, string> pair in services)
            {
                String name = pair.Key.Substring(prefix.Length);
                for(int i = 0; i < argSeq.Count; ++i)
                {
                    if(argSeq[i].StartsWith("--" + name, StringComparison.CurrentCulture))
                    {
                        argSeq.RemoveAt(i);
                        i--;
                    }
                }
            }

            foreach(String s in argSeq)
            {
                if(s.Equals("-h") || s.Equals("--help"))
                {
                    usage();
                    return 0;
                }
                else
                {
                    Console.Error.WriteLine("Server: unknown option `" + s + "'");
                    usage();
                    return 1;
                }
            }

            ServiceManagerI serviceManagerImpl = new ServiceManagerI(communicator(), args);
            return serviceManagerImpl.run();
        }
예제 #5
0
파일: Server.cs 프로젝트: chuanqingli/ice
        public static int Main(string[] args)
        {
            int           status = 0;
            List <string> argSeq = new List <string>();
            const string  prefix = "IceBox.Service.";

            Ice.InitializationData initData = new Ice.InitializationData();
            initData.properties = Ice.Util.createProperties();
            initData.properties.setProperty("Ice.Admin.DelayCreation", "1");

            try
            {
                using (var communicator = Ice.Util.initialize(ref args, initData))
                {
                    Console.CancelKeyPress += (sender, eventArgs) =>
                    {
                        eventArgs.Cancel = true;
                        communicator.shutdown();
                    };

                    Ice.Properties properties            = communicator.getProperties();
                    Dictionary <string, string> services = properties.getPropertiesForPrefix(prefix);

                    foreach (string arg in argSeq)
                    {
                        bool valid = false;
                        foreach (KeyValuePair <string, string> pair in services)
                        {
                            string name = pair.Key.Substring(prefix.Length);
                            if (arg.StartsWith("--" + name, StringComparison.CurrentCulture))
                            {
                                valid = true;
                                break;
                            }
                        }
                        if (!valid)
                        {
                            if (arg.Equals("-h") || arg.Equals("--help"))
                            {
                                usage();
                                status = 1;
                                break;
                            }
                            else if (arg.Equals("-v") || arg.Equals("--version"))
                            {
                                Console.Out.WriteLine(Ice.Util.stringVersion());
                                status = 1;
                                break;
                            }
                            else
                            {
                                Console.Error.WriteLine("IceBox.Server: unknown option `" + arg + "'");
                                usage();
                                status = 1;
                                break;
                            }
                        }
                    }

                    ServiceManagerI serviceManagerImpl = new ServiceManagerI(communicator, argSeq.ToArray());
                    status = serviceManagerImpl.run();
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
                status = 1;
            }

            return(status);
        }