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

Commit 837ebe6

Browse files
committed
Fixes #9 - PropertyListValueConverter.ConvertSourceToObject
If the object-type conversion fails, we check to see if a direct casting would work.
1 parent 250509e commit 837ebe6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Our.Umbraco.PropertyList/ValueConverters/PropertyListValueConverter.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ public override object ConvertSourceToObject(PublishedPropertyType propertyType,
9595
{
9696
result.SetValue(attempt.Result, i);
9797
}
98+
else
99+
{
100+
// NOTE: At this point `TryConvertTo` can't convert to the `targetType`.
101+
// This may be a case where the `targetType` is an interface.
102+
// We can attempt to cast it directly, as a last resort.
103+
if (targetType.IsInstanceOfType(objects[i]))
104+
{
105+
result.SetValue(objects[i], i);
106+
}
107+
}
98108
}
99109

100110
return result;

0 commit comments

Comments
 (0)