public static void ConfigureTargetPath(int indexToUpdate, string newValue, IObjectPath targetPath) { if (targetPath.Count == indexToUpdate) { targetPath.Add(newValue); } else if (string.IsNullOrEmpty(newValue)) { targetPath.RemoveAt(indexToUpdate); } else { targetPath[indexToUpdate] = newValue; } }