Mono.CSharp.Undo.AddTypeContainer C# (CSharp) Method

AddTypeContainer() public method

public AddTypeContainer ( TypeContainer current_container, TypeContainer tc ) : void
current_container TypeContainer
tc TypeContainer
return void
        public void AddTypeContainer(TypeContainer current_container, TypeContainer tc)
        {
            if (current_container == tc){
                Console.Error.WriteLine ("Internal error: inserting container into itself");
                return;
            }

            if (undo_actions == null)
                undo_actions = new List<Action> ();

            var existing = current_container.Types.FirstOrDefault (l => l.MemberName.Basename == tc.MemberName.Basename);
            if (existing != null) {
                current_container.RemoveTypeContainer (existing);
                existing.NamespaceEntry.SlaveDeclSpace.RemoveTypeContainer (existing);
                undo_actions.Add (() => current_container.AddTypeContainer (existing));
            }

            undo_actions.Add (() => current_container.RemoveTypeContainer (tc));
        }