@@ -98,12 +98,8 @@ public PropertyBag(IDictionary<string, object?> properties)
9898 if ( ! TryGetValue ( name , out var value ) || value is null )
9999 return null ;
100100
101- return value switch
102- {
103- DateTime dt => dt ,
104- string s => DateTime . Parse ( s ) ,
105- _ => null ,
106- } ;
101+ var converter = PropertyConverterRegistry . Default . GetConverterForType ( typeof ( DateTime ) ) ;
102+ return ( DateTime ? ) converter ? . FromRest ( value , typeof ( DateTime ) ) ;
107103 }
108104
109105 /// <summary>
@@ -130,17 +126,10 @@ public PropertyBag(IDictionary<string, object?> properties)
130126 if ( ! TryGetValue ( name , out var value ) || value is null )
131127 return null ;
132128
133- if ( value is GeoCoordinate geo )
134- return geo ;
135-
136- if ( value is IDictionary < string , object ? > dict )
137- {
138- var lat = dict . TryGetValue ( "latitude" , out var latVal ) ? Convert . ToSingle ( latVal ) : 0f ;
139- var lon = dict . TryGetValue ( "longitude" , out var lonVal ) ? Convert . ToSingle ( lonVal ) : 0f ;
140- return new GeoCoordinate ( lat , lon ) ;
141- }
142-
143- return null ;
129+ var converter = PropertyConverterRegistry . Default . GetConverterForType (
130+ typeof ( GeoCoordinate )
131+ ) ;
132+ return ( GeoCoordinate ? ) converter ? . FromRest ( value , typeof ( GeoCoordinate ) ) ;
144133 }
145134
146135 /// <summary>
@@ -151,23 +140,8 @@ public PropertyBag(IDictionary<string, object?> properties)
151140 if ( ! TryGetValue ( name , out var value ) || value is null )
152141 return null ;
153142
154- if ( value is PhoneNumber phone )
155- return phone ;
156-
157- if ( value is IDictionary < string , object ? > dict )
158- {
159- var input = dict . TryGetValue ( "input" , out var inputVal )
160- ? inputVal ? . ToString ( ) ?? ""
161- : "" ;
162- return new PhoneNumber ( input )
163- {
164- DefaultCountry = dict . TryGetValue ( "defaultCountry" , out var dc )
165- ? dc ? . ToString ( )
166- : null ,
167- } ;
168- }
169-
170- return null ;
143+ var converter = PropertyConverterRegistry . Default . GetConverterForType ( typeof ( PhoneNumber ) ) ;
144+ return ( PhoneNumber ? ) converter ? . FromRest ( value , typeof ( PhoneNumber ) ) ;
171145 }
172146
173147 /// <summary>
@@ -178,12 +152,8 @@ public PropertyBag(IDictionary<string, object?> properties)
178152 if ( ! TryGetValue ( name , out var value ) || value is null )
179153 return null ;
180154
181- return value switch
182- {
183- byte [ ] bytes => bytes ,
184- string s => Convert . FromBase64String ( s ) ,
185- _ => null ,
186- } ;
155+ var converter = PropertyConverterRegistry . Default . GetConverterForType ( typeof ( byte [ ] ) ) ;
156+ return ( byte [ ] ? ) converter ? . FromRest ( value , typeof ( byte [ ] ) ) ;
187157 }
188158
189159 /// <summary>
0 commit comments