@@ -67,15 +67,15 @@ internal sealed class AutorecoveringConnection : IAutorecoveringConnection
67
67
68
68
private readonly object _recordedEntitiesLock = new object ( ) ;
69
69
70
- private readonly IDictionary < string , RecordedExchange > _recordedExchanges = new Dictionary < string , RecordedExchange > ( ) ;
70
+ private readonly Dictionary < string , RecordedExchange > _recordedExchanges = new Dictionary < string , RecordedExchange > ( ) ;
71
71
72
- private readonly IDictionary < string , RecordedQueue > _recordedQueues = new Dictionary < string , RecordedQueue > ( ) ;
72
+ private readonly Dictionary < string , RecordedQueue > _recordedQueues = new Dictionary < string , RecordedQueue > ( ) ;
73
73
74
- private readonly IDictionary < RecordedBinding , byte > _recordedBindings = new Dictionary < RecordedBinding , byte > ( ) ;
74
+ private readonly Dictionary < RecordedBinding , byte > _recordedBindings = new Dictionary < RecordedBinding , byte > ( ) ;
75
75
76
- private readonly IDictionary < string , RecordedConsumer > _recordedConsumers = new Dictionary < string , RecordedConsumer > ( ) ;
76
+ private readonly Dictionary < string , RecordedConsumer > _recordedConsumers = new Dictionary < string , RecordedConsumer > ( ) ;
77
77
78
- private readonly ICollection < AutorecoveringModel > _models = new List < AutorecoveringModel > ( ) ;
78
+ private readonly List < AutorecoveringModel > _models = new List < AutorecoveringModel > ( ) ;
79
79
80
80
private EventHandler < ConnectionBlockedEventArgs > _recordedBlockedEventHandlers ;
81
81
private EventHandler < ShutdownEventArgs > _recordedShutdownEventHandlers ;
@@ -485,12 +485,11 @@ public void DeleteRecordedBinding(RecordedBinding rb)
485
485
486
486
public RecordedConsumer DeleteRecordedConsumer ( string consumerTag )
487
487
{
488
- RecordedConsumer rc = null ;
488
+ RecordedConsumer rc ;
489
489
lock ( _recordedEntitiesLock )
490
490
{
491
- if ( _recordedConsumers . ContainsKey ( consumerTag ) )
491
+ if ( _recordedConsumers . TryGetValue ( consumerTag , out rc ) )
492
492
{
493
- rc = _recordedConsumers [ consumerTag ] ;
494
493
_recordedConsumers . Remove ( consumerTag ) ;
495
494
}
496
495
}
@@ -912,10 +911,12 @@ private void PropagateQueueNameChangeToBindings(string oldName, string newName)
912
911
{
913
912
lock ( _recordedBindings )
914
913
{
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 )
917
915
{
918
- b . Destination = newName ;
916
+ if ( b . Destination . Equals ( oldName ) )
917
+ {
918
+ b . Destination = newName ;
919
+ }
919
920
}
920
921
}
921
922
}
@@ -924,21 +925,22 @@ private void PropagateQueueNameChangeToConsumers(string oldName, string newName)
924
925
{
925
926
lock ( _recordedConsumers )
926
927
{
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 )
930
929
{
931
- c . Value . Queue = newName ;
930
+ if ( c . Value . Queue . Equals ( oldName ) )
931
+ {
932
+ c . Value . Queue = newName ;
933
+ }
932
934
}
933
935
}
934
936
}
935
937
936
938
private void RecoverBindings ( )
937
939
{
938
- IDictionary < RecordedBinding , byte > recordedBindingsCopy = null ;
940
+ Dictionary < RecordedBinding , byte > recordedBindingsCopy ;
939
941
lock ( _recordedBindings )
940
942
{
941
- recordedBindingsCopy = _recordedBindings . ToDictionary ( e => e . Key , e => e . Value ) ;
943
+ recordedBindingsCopy = new Dictionary < RecordedBinding , byte > ( _recordedBindings ) ;
942
944
}
943
945
944
946
foreach ( RecordedBinding b in recordedBindingsCopy . Keys )
@@ -1031,10 +1033,10 @@ private void RecoverConsumers()
1031
1033
throw new ObjectDisposedException ( GetType ( ) . FullName ) ;
1032
1034
}
1033
1035
1034
- IDictionary < string , RecordedConsumer > recordedConsumersCopy = null ;
1036
+ Dictionary < string , RecordedConsumer > recordedConsumersCopy ;
1035
1037
lock ( _recordedConsumers )
1036
1038
{
1037
- recordedConsumersCopy = _recordedConsumers . ToDictionary ( e => e . Key , e => e . Value ) ;
1039
+ recordedConsumersCopy = new Dictionary < string , RecordedConsumer > ( _recordedConsumers ) ;
1038
1040
}
1039
1041
1040
1042
foreach ( KeyValuePair < string , RecordedConsumer > pair in recordedConsumersCopy )
@@ -1091,10 +1093,10 @@ private void RecoverEntities()
1091
1093
1092
1094
private void RecoverExchanges ( )
1093
1095
{
1094
- IDictionary < string , RecordedExchange > recordedExchangesCopy = null ;
1096
+ Dictionary < string , RecordedExchange > recordedExchangesCopy ;
1095
1097
lock ( _recordedEntitiesLock )
1096
1098
{
1097
- recordedExchangesCopy = _recordedExchanges . ToDictionary ( e => e . Key , e => e . Value ) ;
1099
+ recordedExchangesCopy = new Dictionary < string , RecordedExchange > ( _recordedExchanges ) ;
1098
1100
}
1099
1101
1100
1102
foreach ( RecordedExchange rx in recordedExchangesCopy . Values )
@@ -1125,10 +1127,10 @@ private void RecoverModels()
1125
1127
1126
1128
private void RecoverQueues ( )
1127
1129
{
1128
- IDictionary < string , RecordedQueue > recordedQueuesCopy = null ;
1130
+ Dictionary < string , RecordedQueue > recordedQueuesCopy ;
1129
1131
lock ( _recordedEntitiesLock )
1130
1132
{
1131
- recordedQueuesCopy = _recordedQueues . ToDictionary ( entry => entry . Key , entry => entry . Value ) ;
1133
+ recordedQueuesCopy = new Dictionary < string , RecordedQueue > ( _recordedQueues ) ;
1132
1134
}
1133
1135
1134
1136
foreach ( KeyValuePair < string , RecordedQueue > pair in recordedQueuesCopy )
0 commit comments