@@ -11,7 +11,7 @@ public sealed class DiagnosticContextCollector : IDisposable
1111 {
1212 readonly IDisposable _chainedDisposable ;
1313 readonly object _propertiesLock = new object ( ) ;
14- List < LogEventProperty > _properties = new List < LogEventProperty > ( ) ;
14+ Dictionary < string , LogEventProperty > _properties = new Dictionary < string , LogEventProperty > ( ) ;
1515
1616 /// <summary>
1717 /// Construct a <see cref="DiagnosticContextCollector"/>.
@@ -34,17 +34,7 @@ public void AddOrUpdate(LogEventProperty property)
3434 lock ( _propertiesLock )
3535 {
3636 if ( _properties == null ) return ;
37-
38- for ( var i = 0 ; i < _properties . Count ; ++ i )
39- {
40- if ( _properties [ i ] . Name == property . Name )
41- {
42- _properties [ i ] = property ;
43- return ;
44- }
45- }
46-
47- _properties . Add ( property ) ;
37+ _properties [ property . Name ] = property ;
4838 }
4939 }
5040
@@ -55,11 +45,11 @@ public void AddOrUpdate(LogEventProperty property)
5545 /// </summary>
5646 /// <param name="properties">The collected properties, or null if no collection is active.</param>
5747 /// <returns>True if properties could be collected.</returns>
58- public bool TryComplete ( out List < LogEventProperty > properties )
48+ public bool TryComplete ( out IEnumerable < LogEventProperty > properties )
5949 {
6050 lock ( _propertiesLock )
6151 {
62- properties = _properties ;
52+ properties = _properties ? . Values ;
6353 _properties = null ;
6454 Dispose ( ) ;
6555 return properties != null ;
0 commit comments