File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,19 +14,35 @@ internal class TypeDetailsCache
1414 private static readonly PropertyDetails [ ] _emptyPropertyDetails = Array . Empty < PropertyDetails > ( ) ;
1515 private readonly ConcurrentDictionary < Type , ( PropertyDetails [ ] Properties , bool RequiresAsync ) > _cache = new ( ) ;
1616
17+ public TypeDetailsCache ( )
18+ {
19+ TypeDescriptor . Refreshed += args =>
20+ {
21+ if ( args . TypeChanged is { } type )
22+ {
23+ _cache . TryRemove ( type , out _ ) ;
24+ }
25+ else
26+ {
27+ _cache . Clear ( ) ;
28+ }
29+ } ;
30+ }
31+
1732 public ( PropertyDetails [ ] Properties , bool RequiresAsync ) Get ( Type ? type )
1833 {
1934 if ( type is null )
2035 {
2136 return ( _emptyPropertyDetails , false ) ;
2237 }
2338
24- if ( ! _cache . ContainsKey ( type ) )
39+ ( PropertyDetails [ ] Properties , bool RequiresAsync ) details ;
40+ while ( ! _cache . TryGetValue ( type , out details ) )
2541 {
2642 Visit ( type ) ;
2743 }
2844
29- return _cache [ type ] ;
45+ return details ;
3046 }
3147
3248 private void Visit ( Type type )
You can’t perform that action at this time.
0 commit comments