Dispose MemoryStream in ConvertFrom method of CursorConverter (#3476)

This commit is contained in:
gpetrou 2020-06-23 11:45:04 +01:00 коммит произвёл GitHub
Родитель c231d486a0
Коммит 7f243921e8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 6 добавлений и 8 удалений

Просмотреть файл

@ -55,25 +55,23 @@ namespace System.Windows.Forms
/// </summary>
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is string)
if (value is string s)
{
string text = ((string)value).Trim();
string text = s.Trim();
PropertyInfo[] props = GetProperties();
for (int i = 0; i < props.Length; i++)
foreach (var prop in props)
{
PropertyInfo prop = props[i];
if (string.Equals(prop.Name, text, StringComparison.OrdinalIgnoreCase))
{
object[] tempIndex = null;
return prop.GetValue(null, tempIndex);
return prop.GetValue(null, null);
}
}
}
if (value is byte[])
if (value is byte[] bytes)
{
MemoryStream ms = new MemoryStream((byte[])value);
using MemoryStream ms = new MemoryStream(bytes);
return new Cursor(ms);
}