2018-02-01 08:37:12 +01:00
|
|
|
|
/*
|
|
|
|
|
* 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/.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-02-02 09:18:35 +01:00
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface;
|
2018-02-01 08:37:12 +01:00
|
|
|
|
|
2018-03-06 11:49:51 +01:00
|
|
|
|
namespace SafeExamBrowser.Contracts.Behaviour.OperationModel
|
2018-02-01 08:37:12 +01:00
|
|
|
|
{
|
2018-03-06 11:38:12 +01:00
|
|
|
|
/// <summary>
|
2018-03-06 14:35:10 +01:00
|
|
|
|
/// A sequence of <see cref="IOperation"/>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.
|
2018-03-06 11:38:12 +01:00
|
|
|
|
///
|
2018-03-06 14:35:10 +01:00
|
|
|
|
/// Exemplary execution order for a sequence initialized with operations A, B, C, D:
|
2018-03-06 11:38:12 +01:00
|
|
|
|
///
|
2018-03-06 14:35:10 +01:00
|
|
|
|
/// <see cref="TryPerform"/>: A -> B -> C -> D.
|
|
|
|
|
/// <see cref="TryRepeat"/>: A -> B -> C -> D.
|
|
|
|
|
/// <see cref="TryRevert"/>: D -> C -> B -> A.
|
2018-03-06 11:38:12 +01:00
|
|
|
|
/// </summary>
|
2018-02-01 08:37:12 +01:00
|
|
|
|
public interface IOperationSequence
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2018-02-28 15:49:06 +01:00
|
|
|
|
/// The progress indicator to be used when executing an operation. Will be ignored if <c>null</c>.
|
2018-02-01 08:37:12 +01:00
|
|
|
|
/// </summary>
|
2018-02-02 09:18:35 +01:00
|
|
|
|
IProgressIndicator ProgressIndicator { set; }
|
2018-02-01 08:37:12 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-03-06 14:35:10 +01:00
|
|
|
|
/// Tries to perform the operations of this sequence according to their initialized order. If any operation fails, the already
|
|
|
|
|
/// performed operations will be reverted.
|
2018-02-02 09:18:35 +01:00
|
|
|
|
/// </summary>
|
2018-02-28 15:49:06 +01:00
|
|
|
|
OperationResult TryPerform();
|
2018-02-02 09:18:35 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-03-06 14:35:10 +01:00
|
|
|
|
/// 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.
|
2018-02-01 08:37:12 +01:00
|
|
|
|
/// </summary>
|
2018-02-28 15:49:06 +01:00
|
|
|
|
OperationResult TryRepeat();
|
2018-02-01 08:37:12 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-02-28 15:49:06 +01:00
|
|
|
|
/// Tries to revert the operations of this sequence. Returns <c>true</c> if all operations were reverted without errors,
|
2018-03-06 14:35:10 +01:00
|
|
|
|
/// otherwise <c>false</c>. The reversion of all operations will continue, even if one or multiple operations fail.
|
2018-02-01 08:37:12 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
bool TryRevert();
|
|
|
|
|
}
|
|
|
|
|
}
|