Skip to content

Commit 3c23b4b

Browse files
authored
SerializeV8SimpleObject support for ExpandoObjects (#4959)
fixes #4958
1 parent d0486b3 commit 3c23b4b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

CefSharp.Core.Runtime/Internals/Serialization/V8Serialization.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,18 @@ namespace CefSharp
140140
list->SetString(index, StringUtils::ToNative(Convert::ToString(obj)));
141141
}
142142
}
143+
// ExpandoObject only implements IDictionary<string,object> not the non-generic System.Collection.IDictionary like Dictionary does
144+
else if (type == System::Dynamic::ExpandoObject::typeid)
145+
{
146+
auto subDict = CefDictionaryValue::Create();
147+
auto dict = (System::Collections::Generic::IDictionary<String^, Object^>^) obj;
148+
for each (auto kvp in dict)
149+
{
150+
auto fieldName = StringUtils::ToNative(Convert::ToString(kvp.Key));
151+
SerializeV8SimpleObject(subDict, fieldName, kvp.Value, ancestors, nameConverter);
152+
}
153+
list->SetDictionary(index, subDict);
154+
}
143155
// Serialize dictionary to CefDictionary (key,value pairs)
144156
else if (System::Collections::IDictionary::typeid->IsAssignableFrom(type))
145157
{

0 commit comments

Comments
 (0)