private void BindToList(Control c, IEnumerable bindableObjects, Dictionary<string, List<IControlBinder>> controlBinders, params object[] p)
{
if (c == null) return;
Dictionary<string, Control> dictionary = c.GetControls();
foreach (string key in controlBinders.Keys)
{
// First, check if the control itself needs to be bound
if (c.ID.StartsWith(key))
{
foreach (IControlBinder binder in controlBinders[key])
{
binder.Bind(c, bindableObjects, p);
}
}
if (bindableObjects != null)
{
// Next, check if there are children that need to be bound
string name = key + bindableObjects.GetType().Name.Replace("[]", "");
if (!dictionary.ContainsKey(name)) continue;
foreach (IControlBinder binder in _binders[key])
{
binder.Bind(dictionary[name], bindableObjects);
}
}
}
}