Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit f1475de

Browse files
committed
Add StringCollection deserialization in .NETStandard 1.3
1 parent 50ee2e9 commit f1475de

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/ServiceStack.Text/PclExport.NetStandard.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,33 @@ public override DateTime ParseXsdDateTimeAsUtc(string dateTimeStr)
165165
// return TimeZoneInfo.ConvertTimeToUtc(dateTime);
166166
//}
167167

168+
#if NETSTANDARD1_3
169+
public override ParseStringDelegate GetSpecializedCollectionParseMethod<TSerializer>(Type type)
170+
{
171+
if (type == typeof(StringCollection))
172+
{
173+
return ParseStringCollection<TSerializer>;
174+
}
175+
return null;
176+
}
177+
178+
private static StringCollection ParseStringCollection<TSerializer>(string value) where TSerializer : ITypeSerializer
179+
{
180+
if ((value = DeserializeListWithElements<TSerializer>.StripList(value)) == null) return null;
181+
182+
var result = new StringCollection();
183+
184+
if (value != String.Empty)
185+
{
186+
foreach (var item in DeserializeListWithElements<TSerializer>.ParseStringList(value))
187+
{
188+
result.Add(item);
189+
}
190+
}
191+
192+
return result;
193+
}
194+
#endif
168195
public override Type UseType(Type type)
169196
{
170197
if (type.IsInterface() || type.IsAbstract())
@@ -174,7 +201,6 @@ public override Type UseType(Type type)
174201
return type;
175202
}
176203

177-
178204
public override ParseStringDelegate GetJsReaderParseMethod<TSerializer>(Type type)
179205
{
180206
if (type.AssignableFrom(typeof(System.Dynamic.IDynamicMetaObjectProvider)) ||

tests/ServiceStack.Text.Tests/AdhocModelTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,9 +733,6 @@ public void Deserialize_array_with_null_elements()
733733
}
734734

735735
[Test]
736-
#if NETCORE && !NETSTANDARD1_3
737-
[Ignore("StringCollection is available only since netstandard1.3 platform")]
738-
#endif
739736
public void Can_serialize_StringCollection()
740737
{
741738
var sc = new StringCollection { "one", "two", "three" };

0 commit comments

Comments
 (0)