2021-03-27 14:12:05 +00:00
|
|
|
using Ryujinx.HLE.HOS.Tamper.Conditions;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Tamper.Operations
|
|
|
|
{
|
|
|
|
class IfBlock : IOperation
|
|
|
|
{
|
|
|
|
private ICondition _condition;
|
2021-08-04 20:05:17 +00:00
|
|
|
private IEnumerable<IOperation> _operationsThen;
|
|
|
|
private IEnumerable<IOperation> _operationsElse;
|
2021-03-27 14:12:05 +00:00
|
|
|
|
2021-08-04 20:05:17 +00:00
|
|
|
public IfBlock(ICondition condition, IEnumerable<IOperation> operationsThen, IEnumerable<IOperation> operationsElse)
|
2021-03-27 14:12:05 +00:00
|
|
|
{
|
|
|
|
_condition = condition;
|
2021-08-04 20:05:17 +00:00
|
|
|
_operationsThen = operationsThen;
|
|
|
|
_operationsElse = operationsElse;
|
2021-03-27 14:12:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Execute()
|
|
|
|
{
|
2021-08-04 20:05:17 +00:00
|
|
|
IEnumerable<IOperation> operations = _condition.Evaluate() ? _operationsThen : _operationsElse;
|
|
|
|
|
|
|
|
if (operations == null)
|
2021-03-27 14:12:05 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-08-04 20:05:17 +00:00
|
|
|
foreach (IOperation op in operations)
|
2021-03-27 14:12:05 +00:00
|
|
|
{
|
|
|
|
op.Execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|