Example #1
0
        public bool Equals(Key k)
        {
            // If parameter is null return false:
            if ((object)k == null)
            {
                return false;
            }

            // Return true if the fields match:
            return KEY == k.KEY;
        }
Example #2
0
        //Deserialize
        public void loadFromDisk(IRKMServer rkm)
        {
            //Check if file exists
            String filePath = AppDomain.CurrentDomain.BaseDirectory;
            if (!File.Exists(filePath + m_fileName))
                return;

            Stream stream = new FileStream(m_fileName, FileMode.Open, FileAccess.Read, FileShare.Read);

            BinaryReader reader = new BinaryReader(stream);

            //reading the number of elements of the dictionary
            int count = reader.ReadInt32();

            m_pairs = new ConcurrentDictionary<IKey, IValue>();
            for (int n = 0; n < count; n++)
            {
                var key = reader.ReadString();
                var value = reader.ReadString();
                IKey newKey = new Key(key);
                bool canAddKey = rkm.addKey(newKey);
                if (canAddKey)
                    m_pairs.TryAdd(newKey, new Value(value));
            }

            stream.Close();
        }
Example #3
0
 private void Btn_ListPairs_Click(object sender, RoutedEventArgs e)
 {
     TextBox_Errors.Text = "";
     IKey k = new IServerNS.Key(TextBox_ShowValue.Text);
     //IValue v = (IServerNS.Value)m_serverProxy.readPair(k);
     m_readPairDelegate.BeginInvoke(k, m_readPairCompleteCallback, k);
     ShowMessage(string.Format("Reading value for key = {0}", k.KEY), false);
 }
Example #4
0
 private void Btn_DeletePairs_Click(object sender, RoutedEventArgs e)
 {
     TextBox_Errors.Text = "";
     IKey k = new IServerNS.Key(TextBox_ShowValue.Text);
     m_deletePairDelegate.BeginInvoke(k, true, m_deletePairCallback, k);
     ShowMessage(string.Format("Deleting key = {0}", k.KEY), false);
 }
Example #5
0
 private void Btn_InsertPair_Click(object sender, RoutedEventArgs e)
 {
     TextBox_Errors.Text = "";
     IKey k = new IServerNS.Key(TextBox_Key.Text);
     IValue v = new IServerNS.Value(TextBox_Value.Text);
     //bool canAddKey = m_serverProxy.storePair(k, v);
     m_storePairDelegate.BeginInvoke(k, v, m_storePairCompleteCallback, k /* state will be the key we added */);
     ShowMessage(string.Format("Storing pair {0} : {1}", k.KEY, v.VAL), false);
 }