2021-03-27 07:12:05 -07: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 13:05:17 -07:00
|
|
|
private IEnumerable<IOperation> _operationsThen;
|
|
|
|
private IEnumerable<IOperation> _operationsElse;
|
2021-03-27 07:12:05 -07:00
|
|
|
|
2021-08-04 13:05:17 -07:00
|
|
|
public IfBlock(ICondition condition, IEnumerable<IOperation> operationsThen, IEnumerable<IOperation> operationsElse)
|
2021-03-27 07:12:05 -07:00
|
|
|
{
|
|
|
|
_condition = condition;
|
2021-08-04 13:05:17 -07:00
|
|
|
_operationsThen = operationsThen;
|
|
|
|
_operationsElse = operationsElse;
|
2021-03-27 07:12:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Execute()
|
|
|
|
{
|
2021-08-04 13:05:17 -07:00
|
|
|
IEnumerable<IOperation> operations = _condition.Evaluate() ? _operationsThen : _operationsElse;
|
|
|
|
|
|
|
|
if (operations == null)
|
2021-03-27 07:12:05 -07:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-08-04 13:05:17 -07:00
|
|
|
foreach (IOperation op in operations)
|
2021-03-27 07:12:05 -07:00
|
|
|
{
|
|
|
|
op.Execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|