コード例 #1
0
        static void Main(string[] args)
        {
            BrokerClient client = null;

            try
            {
                client = new BrokerClient();
                Console.WriteLine("Username : "******"0" + i;
                    v.value = "a" + i;
                    client.StorePair(k, v, myid);
                    Console.WriteLine(i);
                }
                Console.WriteLine("done store");

                for (int i = 0; i < 10; i++)
                {
                    IKey k = new Key();
                    k.key = "0" + i;
                    IValue v = (IValue)client.ReadPair(k);
                    Console.WriteLine(v.value);
                }
                Console.WriteLine("done read");

                object[] aux = (object[])client.GetAllPairs(myid);

                for (int i = 0; i < aux.Length; ++i)
                {
                    KeyValuePair <object, object>[] a = (KeyValuePair <object, object>[])aux[i];

                    foreach (KeyValuePair <object, object> pair in a)
                    {
                        Console.WriteLine("Key - {0} , Value - {1}", ((IKey)pair.Key).key, ((IValue)pair.Value).value);
                    }
                }

                client.Close();
            }
            catch (TimeoutException)
            {
                Console.WriteLine("Service operation time out");
                client.Abort();
            }
            catch (FaultException exception)
            {
                Console.WriteLine(exception.Message);
                client.Abort();
            }
            catch (CommunicationException)
            {
                Console.WriteLine("communication problem");
                client.Abort();
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: pepipe/ISEL
        static void Main(string[] args)
        {
            BrokerClient prx = new BrokerClient();
            Pair p = new Pair();

            IContextManager ctxManager = prx.InnerChannel.GetProperty<IContextManager>();
            IDictionary<string, string> context = ctxManager.GetContext();

            context["clientName"] = "Client1";
            ctxManager.SetContext(context);

            for (int i = 0; i < 50; ++i)
            {
                p.Key = "" + i;
                p.Value = "My val " + i;

                try
                {
                    prx.StorePair(p);
                }
                catch (FaultException e)
                {
                    Console.WriteLine(e.Reason);
                }
            }

            Console.WriteLine("Keys Added. Press any key to exit.");
            Console.ReadLine();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Baptista/SD
        static void Main(string[] args)
        {
            BrokerClient client = null;
            try
            {
                client = new BrokerClient();
                Console.WriteLine("Username : "******"0" + i;
                    v.value = "a" + i;
                    client.StorePair(k, v, myid);
                    Console.WriteLine(i);
                }
                Console.WriteLine("done store");

                for (int i = 0; i < 10; i++)
                {
                    IKey k = new Key();
                    k.key = "0" + i;
                    IValue v = (IValue)client.ReadPair(k);
                    Console.WriteLine(v.value);
                }
                Console.WriteLine("done read");

                object[] aux = (object[])client.GetAllPairs(myid);

                for (int i = 0; i < aux.Length; ++i)
                {
                    KeyValuePair<object, object>[] a = (KeyValuePair<object, object>[])aux[i];

                    foreach (KeyValuePair<object, object> pair in a)
                    {
                        Console.WriteLine("Key - {0} , Value - {1}", ((IKey)pair.Key).key, ((IValue)pair.Value).value);
                    }
                }

                client.Close();
            }
            catch (TimeoutException)
            {
                Console.WriteLine("Service operation time out");
                client.Abort();
            }
            catch (FaultException exception)
            {

                Console.WriteLine(exception.Message);
                client.Abort();
            }
            catch (CommunicationException)
            {
                Console.WriteLine("communication problem");
                client.Abort();
            }
        }