Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
0
Archivo: Pair.cs Proyecto: Baptista/SD
 public bool Equals(Key k)
 {
     return key.Equals(k.key);
 }