Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add overloads to CanFire to support trigger parameters #574

Merged

Conversation

mclift
Copy link
Member

@mclift mclift commented May 12, 2024

To address #550

This PR adds support for trigger parameters to CanFire. Example:

const int argument0 = 101;
var sm = new StateMachine<string, string>("StateA");
var valueTrigger = sm.SetTriggerParameters<int>("MyTrigger");
sm.Configure("StateA").PermitIf(valueTrigger, "StateB", i => i > 100);

Console.WriteLine($"CanFire with {valueTrigger.Trigger} " +
    $"on state {sm.State} " +
    $"with parameter value {argument0} " +
    $"returns: {sm.CanFire(valueTrigger, argument0)}.");

// Output:
// CanFire with MyTrigger on state StateA with parameter value 101 returns: True.

This PR does not change the existing behavior of bool CanFire(TTrigger) nor of bool CanFire(TTrigger, out ICollection<string>), but xmldoc remarks have been added to clarify that they may not work as expected when used with parameterized triggers.

@crozone
Copy link
Collaborator

crozone commented May 13, 2024

LGTM!

@mclift mclift merged commit 2e79d56 into dotnet-state-machine:dev May 13, 2024
1 check passed
This was referenced May 21, 2024
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants