@@ -9,22 +9,34 @@ public class VersionStrategiesConverter : IYamlTypeConverter
99{
1010 public static readonly IYamlTypeConverter Instance = new VersionStrategiesConverter ( ) ;
1111
12- public bool Accepts ( Type type )
13- {
14- return type == typeof ( VersionStrategies [ ] ) ;
15- }
12+ public bool Accepts ( Type type ) => type == typeof ( VersionStrategies [ ] ) ;
1613
1714 public object ? ReadYaml ( IParser parser , Type type , ObjectDeserializer rootDeserializer )
1815 {
19- string data = parser . Consume < Scalar > ( ) . Value ;
20-
21- var deserializer = new DeserializerBuilder ( )
22- . WithNamingConvention ( UnderscoredNamingConvention . Instance ) // see height_in_inches in sample yml
23- . Build ( ) ;
24-
25- VersionStrategies [ ] strategies = deserializer . Deserialize < VersionStrategies [ ] > ( data ) ;
26-
27- return strategies ;
16+ List < VersionStrategies > strategies = new ( ) ;
17+
18+ if ( parser . TryConsume < SequenceStart > ( out var _ ) )
19+ {
20+ while ( ! parser . TryConsume < SequenceEnd > ( out var _ ) )
21+ {
22+ string data = parser . Consume < Scalar > ( ) . Value ;
23+
24+ var strategy = Enum . Parse < VersionStrategies > ( data ) ;
25+ strategies . Add ( strategy ) ;
26+ }
27+ }
28+ else
29+ {
30+ string data = parser . Consume < Scalar > ( ) . Value ;
31+
32+ var deserializer = new DeserializerBuilder ( )
33+ . WithNamingConvention ( UnderscoredNamingConvention . Instance ) // see height_in_inches in sample yml
34+ . Build ( ) ;
35+
36+ strategies = deserializer . Deserialize < List < VersionStrategies > > ( data ) ;
37+ }
38+
39+ return strategies . ToArray ( ) ;
2840 }
2941
3042 public void WriteYaml ( IEmitter emitter , object ? value , Type type , ObjectSerializer serializer )
0 commit comments