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

Extension.EnteredInitialState has context.State == null #33

Open
fubar-coder opened this issue Mar 16, 2018 · 4 comments
Open

Extension.EnteredInitialState has context.State == null #33

fubar-coder opened this issue Mar 16, 2018 · 4 comments

Comments

@fubar-coder
Copy link

This prevents getting the IState<TState, TEvent> of the initial status.

Example extension code:

private class CurrentStatusExtension : AsyncExtensionBase<States, Triggers>
{
	private readonly AppccelerateTestData _instance;

	public CurrentStatusExtension(AppccelerateTestData instance)
	{
		_instance = instance;
	}

	public override void EnteredInitialState(
		IStateMachineInformation<States, Triggers> stateMachine,
		States state,
		ITransitionContext<States, Triggers> context)
	{
		// context.State is null ... so there is no way to get the initial state?
		_instance.CurrentStatus = context.State;
	}
}
@ursenzler
Copy link
Member

Use the state passed to the method directly. The state of the context is the source state, which is null in case of initialization.

Does this work for you?

@fubar-coder
Copy link
Author

No, sorry, I need the IState, because I need to get the valid triggers.

@ursenzler
Copy link
Member

I see.

That can be accomplished by changing the code in the method Appccelerate.StateMachine.AsyncMachine.StateMachine.Initialize on line 193 so that it passes the IState to the extension (the same value is already passed to a method the line before).

If you want the change quickly, I suggest you change the code as explained above and compile the state machine on your own. Otherwise, you'll have to wait for me and my time is very limited at the moment.

See http://www.appccelerate.com/howtocontributewalkthrough.html for an explanation how to get your own nuget package easily from our build infrastructure through a pull request.

I hope that helps.
Urs

@fubar-coder
Copy link
Author

Maybe it might be useful to add a property containing the target state? My assumption was that the context state always contains the target state for all transitioned/initialized events.

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

No branches or pull requests

2 participants