public void AddBefore(ScriptLine newLine, ScriptLine destination) { if (destination == null || ScriptLines.IndexOf(destination) == -1) { destination = ScriptLines.Where(a => a.GetType() == typeof(Blank)).FirstOrDefault(); } var index = ScriptLines.IndexOf(destination); ScriptLines.Insert(index, newLine); }