public void OnJavaScriptObjectChanges(IJavascriptObject objectchanged, string propertyName, IJavascriptObject newValue)
{
try
{
var res = _SessionCache.GetGlobalCached(objectchanged) as JsGenericObject;
if (res == null)
return;
var propertyAccessor = new PropertyAccessor(res.CValue, propertyName, _Logger);
if (!propertyAccessor.IsSettable)
{
_Logger.Info(() => $"Unable to set C# from javascript object: property: {propertyName} is readonly.");
return;
}
var targetType = propertyAccessor.GetTargetType();
var glue = GetCachedOrCreateBasic(newValue, targetType);
using (_IsListening ? _ListenerRegister.GetPropertySilenter(res.CValue) : null)
{
propertyAccessor.Set(glue.CValue);
res.UpdateCSharpProperty(propertyName, glue);
}
}
catch (Exception e)
{
_Logger.Error(() =>$"Unable to update ViewModel from View, exception raised: {e.Message}");
}
}