Implemented exception handling if the property cannot be read. Not 100% sure about this one, but in some way it feels best to propagate a CLR exception into the exception output variable.

This commit is contained in:
Per Lundberg
2013-05-11 09:30:44 +03:00
committed by Per Lundberg
parent 11092e383c
commit f5b2ce92d3
+15 -6
View File
@@ -21,22 +21,31 @@ namespace CefSharp
CefString& exception) override
{
auto unmanagedWrapper = static_cast<UnmanagedWrapper*>(object->GetUserData().get());
String^ clrName = toClr(name);
auto clrName = toClr(name);
PropertyInfo^ property;
if (unmanagedWrapper->Properties->TryGetValue(clrName, property))
{
Object^ wrappedObject = unmanagedWrapper->Get();
if(wrappedObject == nullptr)
auto wrappedObject = unmanagedWrapper->Get();
if (wrappedObject == nullptr)
{
exception = "Binding's CLR object is null.";
return true;
}
Object^ clrValue = property->GetValue(wrappedObject, nullptr);
try
{
auto clrValue = property->GetValue(wrappedObject, nullptr);
retval = convertToCef(clrValue, nullptr);
return true;
retval = convertToCef(clrValue, nullptr);
return true;
}
catch (Exception^ e)
{
exception = toNative(e->Message);
return true;
}
}
else
{