Skip to content

louissalin/StateUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This state machine lets you use Ninject and declare your bindings in contexts that are associated with states in the state machine. This way, bindings are executed by the Ninject module only if the associated state is the current state.

For example, reusing the samurai examples from Ninject's own website, you can write:

	sm = new StateMachine();
	sm.AddState(s => s.Name = "UseSword");
	sm.AddState(s => s.Name = "LoseSword");
	sm.CreatePathFrom.State("UseSword").To.State("LoseSword");

	// when starting the state machine, the first state declared
	// is automatically loaded. So "UseSword" is the current inital state.
	sm.Start();

	LoadKernel();
	var samurai = _kernel.Get<Samurai>();
	samurai.Attack();

	sm.ChangeState("LoseSword");
	LoadKernel();

	samurai = _kernel.Get<Samurai>();
	samurai.Attack();

which results in the following being outputed:

	Attacking with a sword!
	Attacking with my bare hands!

Please refer to the ConsoleSamurai sample in the src/Samples directory for the complete code.

Compiling:
---------

To compile, download NInject and add NInject.dll to the lib/ folder. If you'll want to run the unit tests, you will need nunit.framework.dll and SpecUnit.dll in the lib/ folder also. Make sure that the nunit dll is of the same version as the one used to compile SpecUnit.

If you are on Windows, well... I hope makefiles work fine on Windows!
More serioulsy, it might not be so hard to create a solution file for this or to make the makefile work.

$ make

This will make the libraries, but won't compile the tests.

$ make samples

This will build the sample projects.

$ make all

This will compile everything.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published