// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using FlaxEngine;
namespace FlaxEditor
{
///
/// Helper class to record undo operations in a block with using keyword. Records changes for one or more objects.
///
///
/// using(new UndoMultiBlock(undo, objs, "Rename objects"))
/// {
/// foreach(var e in objs)
/// e.Name = "super name";
/// }
///
///
[HideInEditor]
public class UndoMultiBlock : IDisposable
{
private readonly object[] _snapshotUndoInternal;
private readonly Undo _undo;
private readonly IUndoAction _customActionBefore;
private readonly IUndoAction _customActionAfter;
///
/// Creates new undo object for recording actions with using pattern.
///
/// The undo/redo object.
/// Instances of objects to record.
/// Name of action to be displayed in undo stack.
/// Custom action to append to the undo block action before recorded modifications apply.
/// Custom action to append to the undo block action after recorded modifications apply.
public UndoMultiBlock(Undo undo, IEnumerable