Removing the try catch, swallowing exceptions.

Made the INetJsValue.AsList method more friendly to different types.
This commit is contained in:
Paul Knopf 2018-12-30 00:32:05 +00:00
parent df051b8582
commit 9e213aac55

View file

@ -1,4 +1,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
namespace Qml.Net.Extensions
{
@ -17,23 +19,19 @@ namespace Qml.Net.Extensions
return null;
}
var destinationConverter = TypeDescriptor.GetConverter(typeof(T));
var list = new List<T>();
try
{
var length = (int)value.GetProperty("length");
for (var i = 0; i < length; i++)
{
var item = value.GetItemAtIndex(i);
list.Add((T)item);
list.Add((T)destinationConverter.ConvertFrom(null, CultureInfo.InvariantCulture, item));
}
return list;
}
catch
{
return null;
}
}
}
}