namespace Jint;
public partial class Engine
{
public ConstraintOperations Constraints { get; }
public class ConstraintOperations
{
private readonly Engine _engine;
internal ConstraintOperations(Engine engine)
{
_engine = engine;
}
///
/// Checks engine's active constraints. Propagates exceptions from constraints.
///
public void Check()
{
foreach (var constraint in _engine._constraints)
{
constraint.Check();
}
}
///
/// Return the first constraint that matches the predicate.
///
public T? Find() where T : Constraint
{
foreach (var constraint in _engine._constraints)
{
if (constraint.GetType() == typeof(T))
{
return (T) constraint;
}
}
return null;
}
///
/// Resets all execution constraints back to their initial state.
///
public void Reset()
{
foreach (var constraint in _engine._constraints)
{
constraint.Reset();
}
}
}
}