@@ -46,7 +46,7 @@ public virtual IEnumerable<Message> AllMessages
4646 MessageLock . EnterReadLock ( ) ;
4747 try
4848 {
49- return MessageList ;
49+ return MessageList . ToList ( ) ;
5050 }
5151 finally
5252 {
@@ -66,11 +66,19 @@ public virtual IEnumerable<Message> MessagesToShow(int count = 5, string? sectio
6666 MessageLock . EnterReadLock ( ) ;
6767 try
6868 {
69- var messages = string . IsNullOrEmpty ( section )
70- ? MessageList
71- : MessageList . Where ( x => x . Section == section ) ;
69+ IEnumerable < Message > messages = MessageList ;
7270
73- return count > 0 ? messages . Take ( count ) : messages ;
71+ if ( ! string . IsNullOrEmpty ( section ) )
72+ {
73+ messages = messages . Where ( x => x . Section == section ) ;
74+ }
75+
76+ if ( count > 0 )
77+ {
78+ messages = messages . Take ( count ) ;
79+ }
80+
81+ return messages . ToList ( ) ;
7482 }
7583 finally
7684 {
@@ -128,7 +136,7 @@ public Message ShowMessageBar(string title, MessageIntent intent, string section
128136 /// <summary>
129137 /// Show a message based on the provided parameters in a message bar.
130138 /// </summary>
131- /// <param name="title"> Main info.
139+ /// <param name="title"> Main info.
132140 /// Using MarkupString can introduce XSS vulnerabilities because it renders unencoded HTML.
133141 /// Only use it with fully trusted, sanitized content.</param>
134142 /// <param name="intent">Intent of the message</param>
@@ -223,7 +231,7 @@ public async Task<Message> ShowMessageBarAsync(string title, MessageIntent inten
223231 /// <summary>
224232 /// Show a message based on the provided parameters in a message bar.
225233 /// </summary>
226- /// <param name="title"> Main info.
234+ /// <param name="title"> Main info.
227235 /// Using MarkupString can introduce XSS vulnerabilities because it renders unencoded HTML.
228236 /// Only use it with fully trusted, sanitized content.</param>
229237 /// <param name="intent">Intent of the message</param>
@@ -263,7 +271,10 @@ public virtual async Task<Message> ShowMessageBarAsync(Action<MessageOptions> op
263271 MessageLock . ExitWriteLock ( ) ;
264272 }
265273
266- await OnMessageItemsUpdatedAsync ! . Invoke ( ) ;
274+ if ( OnMessageItemsUpdatedAsync is { } handler )
275+ {
276+ await handler . Invoke ( ) ;
277+ }
267278
268279 return message ;
269280 }
@@ -326,10 +337,7 @@ private void NavigationManager_LocationChanged(object? sender, LocationChangedEv
326337 /// <summary />
327338 public void Dispose ( )
328339 {
329- if ( _navigationManager != null )
330- {
331- _navigationManager . LocationChanged -= NavigationManager_LocationChanged ;
332- }
340+ _navigationManager ? . LocationChanged - = NavigationManager_LocationChanged ;
333341
334342 RemoveMessageItems ( section : null ) ;
335343 }
0 commit comments