Пример #1
0
 private void UpdateSavedState(EndpointManager.Link key, EndpointManager.ResendState expectedState)
 {
     if (expectedState == null)
     {
         if (_receiveBuffers.ContainsKey(key))
         {
             var updatedValue = new EndpointManager.ResendState(_uid, _ackedReceiveBuffer);
             _receiveBuffers.AddOrUpdate(key, updatedValue, (link, state) => updatedValue);
             UpdateSavedState(key, updatedValue);
         }
     }
     else
     {
         var canReplace = _receiveBuffers.ContainsKey(key) && _receiveBuffers[key].Equals(expectedState);
         if (canReplace)
         {
             _receiveBuffers[key] = Merge(new EndpointManager.ResendState(_uid, _ackedReceiveBuffer),
                 expectedState);
         }
         else
         {
             EndpointManager.ResendState previousValue;
             _receiveBuffers.TryGetValue(key, out previousValue);
             UpdateSavedState(key, previousValue);
         }
     }
 }