public void AddTypeContainer(TypeContainer current_container, TypeDefinition tc) { if (current_container == tc) { Console.Error.WriteLine("Internal error: inserting container into itself"); return; } if (undo_actions == null) { undo_actions = new List <Action> (); } if (current_container.Containers != null) { var existing = current_container.Containers.FirstOrDefault(l => l.MemberName.Basename == tc.MemberName.Basename); if (existing != null) { current_container.RemoveContainer(existing); undo_actions.Add(() => current_container.AddTypeContainer(existing)); } } undo_actions.Add(() => current_container.RemoveContainer(tc)); }