Added custom type conversion support to the SaveTo method of DefaultConnectionInfo

This commit is contained in:
David Sparer
2016-08-12 13:05:44 -06:00
parent 0df478d2aa
commit 682dc36d34

View File

@@ -43,7 +43,13 @@ namespace mRemoteNG.Connection
{
var propertyFromSettings = typeof(TDestination).GetProperty(propertyNameMutator(property.Name));
var localValue = property.GetValue(Instance, null);
propertyFromSettings.SetValue(destinationInstance, localValue, null);
var descriptor = TypeDescriptor.GetProperties(Instance)[property.Name];
var converter = descriptor.Converter;
if (converter != null && converter.CanConvertFrom(localValue.GetType()))
property.SetValue(Instance, converter.ConvertFrom(localValue), null);
else
propertyFromSettings.SetValue(destinationInstance, localValue, null);
}
}
}