Restore SEBPatch
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Core.Contracts.OperationModel.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for all event arguments used for <see cref="IOperationSequence.ActionRequired"/>.
|
||||
/// </summary>
|
||||
public abstract class ActionRequiredEventArgs
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Core.Contracts.OperationModel.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Event handler used to indicate that an <see cref="IOperation"/> requires user interaction.
|
||||
/// </summary>
|
||||
public delegate void ActionRequiredEventHandler(ActionRequiredEventArgs args);
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Core.Contracts.OperationModel.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// The event arguments used for <see cref="IOperationSequence.ProgressChanged"/>.
|
||||
/// </summary>
|
||||
public class ProgressChangedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the current progress value, if set.
|
||||
/// </summary>
|
||||
public int? CurrentValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the progress value is indeterminate, if set.
|
||||
/// </summary>
|
||||
public bool? IsIndeterminate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the maximum progress value, if set.
|
||||
/// </summary>
|
||||
public int? MaxValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the current progress value has increased by 1, if set.
|
||||
/// </summary>
|
||||
public bool? Progress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the current progress value has decreased by 1, if set.
|
||||
/// </summary>
|
||||
public bool? Regress { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Core.Contracts.OperationModel.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Event handler used to indicate that the progress of an <see cref="IOperationSequence"/> has changed.
|
||||
/// </summary>
|
||||
public delegate void ProgressChangedEventHandler(ProgressChangedEventArgs args);
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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.I18n.Contracts;
|
||||
|
||||
namespace SafeExamBrowser.Core.Contracts.OperationModel.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Event handler used to indicate that the status of an <see cref="IOperation"/> has changed.
|
||||
/// </summary>
|
||||
public delegate void StatusChangedEventHandler(TextKey status);
|
||||
}
|
38
SafeExamBrowser.Core.Contracts/OperationModel/IOperation.cs
Normal file
38
SafeExamBrowser.Core.Contracts/OperationModel/IOperation.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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.Core.Contracts.OperationModel.Events;
|
||||
|
||||
namespace SafeExamBrowser.Core.Contracts.OperationModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines an operation which will be executed as part of an <see cref="IOperationSequence"/>.
|
||||
/// </summary>
|
||||
public interface IOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// Event fired when the operation requires user interaction.
|
||||
/// </summary>
|
||||
event ActionRequiredEventHandler ActionRequired;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the status of the operation has changed.
|
||||
/// </summary>
|
||||
event StatusChangedEventHandler StatusChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Performs the operation.
|
||||
/// </summary>
|
||||
OperationResult Perform();
|
||||
|
||||
/// <summary>
|
||||
/// Reverts all changes made when executing the operation.
|
||||
/// </summary>
|
||||
OperationResult Revert();
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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.Core.Contracts.OperationModel.Events;
|
||||
|
||||
namespace SafeExamBrowser.Core.Contracts.OperationModel
|
||||
{
|
||||
/// <summary>
|
||||
/// A sequence of <see cref="IOperation"/> 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:
|
||||
///
|
||||
/// <see cref="TryPerform"/>: A -> B -> C -> D.
|
||||
/// <see cref="TryRevert"/>: D -> C -> B -> A.
|
||||
/// </summary>
|
||||
public interface IOperationSequence
|
||||
{
|
||||
/// <summary>
|
||||
/// Event fired when an operation requires user interaction.
|
||||
/// </summary>
|
||||
event ActionRequiredEventHandler ActionRequired;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the progress of the sequence has changed.
|
||||
/// </summary>
|
||||
event ProgressChangedEventHandler ProgressChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the status of an operation has changed.
|
||||
/// </summary>
|
||||
event StatusChangedEventHandler StatusChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Tries to perform the operations of this sequence according to their initialized order. If any operation fails, the already
|
||||
/// performed operations will be reverted.
|
||||
/// </summary>
|
||||
OperationResult TryPerform();
|
||||
|
||||
/// <summary>
|
||||
/// Tries to revert the operations of this sequence in reversion of their initialized order. The reversion of all operations will
|
||||
/// continue, even if one or multiple operations fail to revert successfully.
|
||||
/// </summary>
|
||||
OperationResult TryRevert();
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Core.Contracts.OperationModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines an operation which can be executed multiple times as part of an <see cref="IRepeatableOperationSequence"/>.
|
||||
/// </summary>
|
||||
public interface IRepeatableOperation : IOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// Repeats the operation.
|
||||
/// </summary>
|
||||
OperationResult Repeat();
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Core.Contracts.OperationModel
|
||||
{
|
||||
/// <summary>
|
||||
/// A sequence of <see cref="IRepeatableOperation"/> which can be used for repeatable sequential procedures.
|
||||
///
|
||||
/// Exemplary execution order for a sequence initialized with operations A, B, C, D:
|
||||
///
|
||||
/// <see cref="TryRepeat()"/>: A -> B -> C -> D.
|
||||
/// </summary>
|
||||
public interface IRepeatableOperationSequence : IOperationSequence
|
||||
{
|
||||
/// <summary>
|
||||
/// Tries to repeat the operations of this sequence according to their initialized order. If any operation fails, the already
|
||||
/// repeated operations will not be reverted.
|
||||
/// </summary>
|
||||
OperationResult TryRepeat();
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Core.Contracts.OperationModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the operation result of the execution of an <see cref="IOperation"/> resp. <see cref="IOperationSequence"/>.
|
||||
/// </summary>
|
||||
public enum OperationResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the operation has been aborted due to an expected condition, e.g. as result of a user decision.
|
||||
/// </summary>
|
||||
Aborted = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the operation has failed due to an invalid or unexpected condition.
|
||||
/// </summary>
|
||||
Failed,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the operation has been executed successfully.
|
||||
/// </summary>
|
||||
Success
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user