private void InternalBindToControl(object source, Control 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 sourceProperties = source.GetType().GetProperties();
var controls = GetControlsFor(destination);
foreach (var control in controls)
{
var controlName = _controlPrefix == null ? control.Name : _controlPrefix.RemovePrefix(control.Name);
var alias = aliases.FirstOrDefault(x => string.Equals(x.DestinationAlias, controlName, StringComparison.OrdinalIgnoreCase));
var finalControlName = alias == null ? controlName : alias.Property;
var sourceProperty = sourceProperties.FirstOrDefault(x => string.Equals(x.Name, finalControlName, StringComparison.OrdinalIgnoreCase));
if (sourceProperty == null) continue;
var strategy = GetStrategyFor(control);
if (source.GetType().GetInterfaces().Any(x => x == typeof(INotifyPropertyChanged)))
strategy.BindControl(control, source, sourceProperty.Name);
else
strategy.SetControlValue(control, source, sourceProperty.Name);
}
}