@@ -190,13 +190,13 @@ select handler.Value
190
190
// For instance, a DataTemplate in a resource dictionary may mark the type as updated in `updatedTypes`
191
191
// but it will not be considered as a new type even if "CreateNewOnMetadataUpdate" was set.
192
192
193
- return ( fe , ImmutableArray < ElementUpdateHandlerActions > . Empty , liveType ) ;
193
+ return ( fe , [ ] , liveType ) ;
194
194
}
195
195
else
196
196
{
197
- return ! handlers . IsDefaultOrEmpty || mappedType is not null
197
+ return ( ! handlers . IsDefaultOrEmpty || mappedType is not null )
198
198
? ( fe , handlers , mappedType )
199
- : default ;
199
+ : ( null , [ ] , null ) ;
200
200
}
201
201
} ,
202
202
parentKey : default ) ;
@@ -208,7 +208,7 @@ select handler.Value
208
208
// or replace the element with a new one
209
209
foreach ( var ( element , elementHandlers , elementMappedType ) in instancesToUpdate )
210
210
{
211
- if ( elementHandlers . IsDefaultOrEmpty )
211
+ if ( element is null )
212
212
{
213
213
continue ;
214
214
}
@@ -218,16 +218,16 @@ select handler.Value
218
218
foreach ( var elementHandler in elementHandlers )
219
219
{
220
220
elementHandler ? . ElementUpdate ( element , updatedTypes ) ;
221
+ }
221
222
222
- if ( elementMappedType is not null )
223
+ if ( elementMappedType is not null )
224
+ {
225
+ if ( _log . IsEnabled ( LogLevel . Trace ) )
223
226
{
224
- if ( _log . IsEnabled ( LogLevel . Trace ) )
225
- {
226
- _log . Error ( $ "Updating element [{ element } ] to [{ elementMappedType } ]") ;
227
- }
228
-
229
- ReplaceViewInstance ( element , elementMappedType , elementHandler ) ;
227
+ _log . Error ( $ "Updating element [{ element } ] to [{ elementMappedType } ]") ;
230
228
}
229
+
230
+ ReplaceViewInstance ( element , elementMappedType , elementHandlers , updatedTypes ) ;
231
231
}
232
232
}
233
233
@@ -413,7 +413,7 @@ private static void UpdateResourceDictionaries(List<Uri> updatedDictionaries, Re
413
413
}
414
414
#endif
415
415
416
- private static void ReplaceViewInstance ( UIElement instance , Type replacementType , ElementUpdateAgent . ElementUpdateHandlerActions ? handler = default , Type [ ] ? updatedTypes = default )
416
+ private static void ReplaceViewInstance ( UIElement instance , Type replacementType , in ImmutableArray < ElementUpdateHandlerActions > handlers , Type [ ] updatedTypes )
417
417
{
418
418
if ( replacementType . GetConstructor ( Array . Empty < Type > ( ) ) is { } creator )
419
419
{
@@ -434,11 +434,17 @@ private static void ReplaceViewInstance(UIElement instance, Type replacementType
434
434
oldStore . ClonePropertiesToAnotherStoreForHotReload ( newStore ) ;
435
435
#endif
436
436
437
- handler ? . BeforeElementReplaced ( instanceFE , newInstanceFE , updatedTypes ) ;
437
+ foreach ( var handler in handlers )
438
+ {
439
+ handler . BeforeElementReplaced ( instanceFE , newInstanceFE , updatedTypes ) ;
440
+ }
438
441
439
442
SwapViews ( instanceFE , newInstanceFE ) ;
440
443
441
- handler ? . AfterElementReplaced ( instanceFE , newInstanceFE , updatedTypes ) ;
444
+ foreach ( var handler in handlers )
445
+ {
446
+ handler . AfterElementReplaced ( instanceFE , newInstanceFE , updatedTypes ) ;
447
+ }
442
448
}
443
449
}
444
450
else
0 commit comments