示例#1
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();
            }
        }
示例#2
0
文件: Pair.cs 项目: Baptista/SD
 public bool Equals(Value obj)
 {
     return this.value.Equals(obj.value);
 }