I am creating my own UI Binding system, which ties controls to their associated objects. What would be better than using a series of if-statements? If I add new controls to serve new track items, I would not want to update this series of if statements every time.
TimelineTrackControl control;
Type objectType = track.GetType();
if (objectType == typeof(ShotTrack))
{
control = new ShotTrackControl();
}
else if (objectType == typeof(AudioTrack))
{
control = new AudioTrackControl();
}
else if (objectType == typeof(GlobalItemTrack))
{
control = new GlobalItemTrackControl();
}
else
{
control = new TimelineTrackControl();
}
control.TargetTrack = track;
timelineTrackMap.Add(track, control);