private void InternalBindToObject(Control source, object destination, IList<BindaAlias> aliases)
{
if (source == null) throw new ArgumentNullException("source");
if (destination == null) throw new ArgumentNullException("destination");
aliases = aliases ?? Enumerable.Empty<BindaAlias>().ToList();
var controls = GetControlsFor(source);
var properties = destination.GetType().GetProperties().Where(property => property.CanWrite);
foreach (var property in properties)
{
var propertyName = property.Name;
var alias = aliases.FirstOrDefault(x => string.Equals(x.Property, property.Name, StringComparison.OrdinalIgnoreCase));
if (alias != null)
propertyName = alias.DestinationAlias;
var control = controls.FirstOrDefault(x => string.Equals(_controlPrefix == null ? x.Name : _controlPrefix.RemovePrefix(x.Name), propertyName, StringComparison.OrdinalIgnoreCase));
if (control == null) continue;
var strategy = GetStrategyFor(control);
var value = strategy.GetControlValue(control);
property.SetValue(destination, value, null);
}
}