Exemple #1
0
    private static int run(Ice.Communicator communicator)
    {
        var proxy = ContextPrxHelper.checkedCast(communicator.propertyToProxy("Context.Proxy"));

        if (proxy == null)
        {
            Console.Error.WriteLine("invalid proxy");
            return(1);
        }

        menu();

        string line = null;

        do
        {
            try
            {
                Console.Out.Write("==> ");
                Console.Out.Flush();
                line = Console.In.ReadLine();
                if (line == null)
                {
                    break;
                }
                if (line.Equals("1"))
                {
                    proxy.call();
                }
                else if (line.Equals("2"))
                {
                    var ctx = new Dictionary <string, string>()
                    {
                        { "type", "Explicit" }
                    };
                    proxy.call(ctx);
                }
                else if (line.Equals("3"))
                {
                    var ctx = new Dictionary <string, string>()
                    {
                        { "type", "Per-Proxy" }
                    };
                    ContextPrxHelper.uncheckedCast(proxy.ice_context(ctx)).call();
                }
                else if (line.Equals("4"))
                {
                    var ic  = communicator.getImplicitContext();
                    var ctx = new Dictionary <string, string>()
                    {
                        { "type", "Implicit" }
                    };
                    ic.setContext(ctx);
                    proxy.call();
                    ctx = new Dictionary <string, string>();
                    ic.setContext(ctx);
                }
                else if (line.Equals("s"))
                {
                    proxy.shutdown();
                }
                else if (line.Equals("x"))
                {
                    // Nothing to do
                }
                else if (line.Equals("?"))
                {
                    menu();
                }
                else
                {
                    Console.WriteLine("unknown command `" + line + "'");
                    menu();
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
            }
        }while (!line.Equals("x"));

        return(0);
    }
Exemple #2
0
        public override int run(string[] args)
        {
            if (args.Length > 0)
            {
                Console.Error.WriteLine(appName() + ": too many arguments");
                return(1);
            }

            ContextPrx proxy = ContextPrxHelper.checkedCast(communicator().propertyToProxy("Context.Proxy"));

            if (proxy == null)
            {
                Console.Error.WriteLine("invalid proxy");
                return(1);
            }

            menu();

            string line = null;

            do
            {
                try
                {
                    Console.Out.Write("==> ");
                    Console.Out.Flush();
                    line = Console.In.ReadLine();
                    if (line == null)
                    {
                        break;
                    }
                    if (line.Equals("1"))
                    {
                        proxy.call();
                    }
                    else if (line.Equals("2"))
                    {
                        Dictionary <string, string> ctx = new Dictionary <string, string>();
                        ctx["type"] = "Explicit";
                        proxy.call(ctx);
                    }
                    else if (line.Equals("3"))
                    {
                        Dictionary <string, string> ctx = new Dictionary <string, string>();
                        ctx["type"] = "Per-Proxy";
                        ContextPrx proxy2 = ContextPrxHelper.uncheckedCast(proxy.ice_context(ctx));
                        proxy2.call();
                    }
                    else if (line.Equals("4"))
                    {
                        Ice.ImplicitContext         ic  = communicator().getImplicitContext();
                        Dictionary <string, string> ctx = new Dictionary <string, string>();
                        ctx["type"] = "Implicit";
                        ic.setContext(ctx);
                        proxy.call();
                        ic.setContext(new Dictionary <string, string>());
                    }
                    else if (line.Equals("s"))
                    {
                        proxy.shutdown();
                    }
                    else if (line.Equals("x"))
                    {
                        // Nothing to do
                    }
                    else if (line.Equals("?"))
                    {
                        menu();
                    }
                    else
                    {
                        Console.WriteLine("unknown command `" + line + "'");
                        menu();
                    }
                }
                catch (System.Exception ex)
                {
                    Console.Error.WriteLine(ex);
                }
            }while (!line.Equals("x"));

            return(0);
        }