@@ -67,15 +67,15 @@ internal sealed class AutorecoveringConnection : IAutorecoveringConnection
6767
6868 private readonly object _recordedEntitiesLock = new object ( ) ;
6969
70- private readonly IDictionary < string , RecordedExchange > _recordedExchanges = new Dictionary < string , RecordedExchange > ( ) ;
70+ private readonly Dictionary < string , RecordedExchange > _recordedExchanges = new Dictionary < string , RecordedExchange > ( ) ;
7171
72- private readonly IDictionary < string , RecordedQueue > _recordedQueues = new Dictionary < string , RecordedQueue > ( ) ;
72+ private readonly Dictionary < string , RecordedQueue > _recordedQueues = new Dictionary < string , RecordedQueue > ( ) ;
7373
74- private readonly IDictionary < RecordedBinding , byte > _recordedBindings = new Dictionary < RecordedBinding , byte > ( ) ;
74+ private readonly Dictionary < RecordedBinding , byte > _recordedBindings = new Dictionary < RecordedBinding , byte > ( ) ;
7575
76- private readonly IDictionary < string , RecordedConsumer > _recordedConsumers = new Dictionary < string , RecordedConsumer > ( ) ;
76+ private readonly Dictionary < string , RecordedConsumer > _recordedConsumers = new Dictionary < string , RecordedConsumer > ( ) ;
7777
78- private readonly ICollection < AutorecoveringModel > _models = new List < AutorecoveringModel > ( ) ;
78+ private readonly List < AutorecoveringModel > _models = new List < AutorecoveringModel > ( ) ;
7979
8080 private EventHandler < ConnectionBlockedEventArgs > _recordedBlockedEventHandlers ;
8181 private EventHandler < ShutdownEventArgs > _recordedShutdownEventHandlers ;
@@ -485,12 +485,11 @@ public void DeleteRecordedBinding(RecordedBinding rb)
485485
486486 public RecordedConsumer DeleteRecordedConsumer ( string consumerTag )
487487 {
488- RecordedConsumer rc = null ;
488+ RecordedConsumer rc ;
489489 lock ( _recordedEntitiesLock )
490490 {
491- if ( _recordedConsumers . ContainsKey ( consumerTag ) )
491+ if ( _recordedConsumers . TryGetValue ( consumerTag , out rc ) )
492492 {
493- rc = _recordedConsumers [ consumerTag ] ;
494493 _recordedConsumers . Remove ( consumerTag ) ;
495494 }
496495 }
@@ -912,10 +911,12 @@ private void PropagateQueueNameChangeToBindings(string oldName, string newName)
912911 {
913912 lock ( _recordedBindings )
914913 {
915- IEnumerable < RecordedBinding > bs = _recordedBindings . Keys . Where ( b => b . Destination . Equals ( oldName ) ) ;
916- foreach ( RecordedBinding b in bs )
914+ foreach ( RecordedBinding b in _recordedBindings . Keys )
917915 {
918- b . Destination = newName ;
916+ if ( b . Destination . Equals ( oldName ) )
917+ {
918+ b . Destination = newName ;
919+ }
919920 }
920921 }
921922 }
@@ -924,21 +925,22 @@ private void PropagateQueueNameChangeToConsumers(string oldName, string newName)
924925 {
925926 lock ( _recordedConsumers )
926927 {
927- IEnumerable < KeyValuePair < string , RecordedConsumer > > cs = _recordedConsumers .
928- Where ( pair => pair . Value . Queue . Equals ( oldName ) ) ;
929- foreach ( KeyValuePair < string , RecordedConsumer > c in cs )
928+ foreach ( KeyValuePair < string , RecordedConsumer > c in _recordedConsumers )
930929 {
931- c . Value . Queue = newName ;
930+ if ( c . Value . Queue . Equals ( oldName ) )
931+ {
932+ c . Value . Queue = newName ;
933+ }
932934 }
933935 }
934936 }
935937
936938 private void RecoverBindings ( )
937939 {
938- IDictionary < RecordedBinding , byte > recordedBindingsCopy = null ;
940+ Dictionary < RecordedBinding , byte > recordedBindingsCopy ;
939941 lock ( _recordedBindings )
940942 {
941- recordedBindingsCopy = _recordedBindings . ToDictionary ( e => e . Key , e => e . Value ) ;
943+ recordedBindingsCopy = new Dictionary < RecordedBinding , byte > ( _recordedBindings ) ;
942944 }
943945
944946 foreach ( RecordedBinding b in recordedBindingsCopy . Keys )
@@ -1031,10 +1033,10 @@ private void RecoverConsumers()
10311033 throw new ObjectDisposedException ( GetType ( ) . FullName ) ;
10321034 }
10331035
1034- IDictionary < string , RecordedConsumer > recordedConsumersCopy = null ;
1036+ Dictionary < string , RecordedConsumer > recordedConsumersCopy ;
10351037 lock ( _recordedConsumers )
10361038 {
1037- recordedConsumersCopy = _recordedConsumers . ToDictionary ( e => e . Key , e => e . Value ) ;
1039+ recordedConsumersCopy = new Dictionary < string , RecordedConsumer > ( _recordedConsumers ) ;
10381040 }
10391041
10401042 foreach ( KeyValuePair < string , RecordedConsumer > pair in recordedConsumersCopy )
@@ -1091,10 +1093,10 @@ private void RecoverEntities()
10911093
10921094 private void RecoverExchanges ( )
10931095 {
1094- IDictionary < string , RecordedExchange > recordedExchangesCopy = null ;
1096+ Dictionary < string , RecordedExchange > recordedExchangesCopy ;
10951097 lock ( _recordedEntitiesLock )
10961098 {
1097- recordedExchangesCopy = _recordedExchanges . ToDictionary ( e => e . Key , e => e . Value ) ;
1099+ recordedExchangesCopy = new Dictionary < string , RecordedExchange > ( _recordedExchanges ) ;
10981100 }
10991101
11001102 foreach ( RecordedExchange rx in recordedExchangesCopy . Values )
@@ -1125,10 +1127,10 @@ private void RecoverModels()
11251127
11261128 private void RecoverQueues ( )
11271129 {
1128- IDictionary < string , RecordedQueue > recordedQueuesCopy = null ;
1130+ Dictionary < string , RecordedQueue > recordedQueuesCopy ;
11291131 lock ( _recordedEntitiesLock )
11301132 {
1131- recordedQueuesCopy = _recordedQueues . ToDictionary ( entry => entry . Key , entry => entry . Value ) ;
1133+ recordedQueuesCopy = new Dictionary < string , RecordedQueue > ( _recordedQueues ) ;
11321134 }
11331135
11341136 foreach ( KeyValuePair < string , RecordedQueue > pair in recordedQueuesCopy )
0 commit comments