/*
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using SafeExamBrowser.Contracts.UserInterface;
namespace SafeExamBrowser.Contracts.Core.OperationModel
{
///
/// A sequence of s which can be used for sequential procedures, e.g. the initialization & finalization of
/// an application component. Each operation will be executed failsafe, i.e. the return value will indicate whether a procedure
/// completed successfully or not.
///
/// Exemplary execution order for a sequence initialized with operations A, B, C, D:
///
/// : A -> B -> C -> D.
/// : A -> B -> C -> D.
/// : D -> C -> B -> A.
///
public interface IOperationSequence
{
///
/// The progress indicator to be used when executing an operation. Will be ignored if null.
///
IProgressIndicator ProgressIndicator { set; }
///
/// Tries to perform the operations of this sequence according to their initialized order. If any operation fails, the already
/// performed operations will be reverted.
///
OperationResult TryPerform();
///
/// Tries to repeat the operations of this sequence according to their initialized order. If any operation fails, the already
/// performed operations will not be reverted.
///
OperationResult TryRepeat();
///
/// Tries to revert the operations of this sequence. Returns true if all operations were reverted without errors,
/// otherwise false. The reversion of all operations will continue, even if one or multiple operations fail.
///
bool TryRevert();
}
}