本文整理汇总了C#中StateMachine.IsComplete方法的典型用法代码示例。如果您正苦于以下问题:C# StateMachine.IsComplete方法的具体用法?C# StateMachine.IsComplete怎么用?C# StateMachine.IsComplete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateMachine
的用法示例。
在下文中一共展示了StateMachine.IsComplete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public static void Run () {
var model = new StateMachine<Instance>("compTest");
var initial = new PseudoState<Instance>("initial", model, PseudoStateKind.Initial);
var activity1 = new State<Instance>("activity1", model);
var activity2 = new State<Instance>("activity2", model);
var activity3 = new State<Instance>("activity3", model);
var junction1 = new PseudoState<Instance>("junction1", model, PseudoStateKind.Junction);
var junction2 = new PseudoState<Instance>("junction2", model, PseudoStateKind.Junction);
var end = new FinalState<Instance>("end", model);
var subInitial = new PseudoState<Instance>("subInitial", activity2, PseudoStateKind.Initial);
var subEnd = new FinalState<Instance>("subEnd", activity2);
subInitial.To(subEnd);
initial.To(activity1);
activity1.To(activity2);
activity2.To(junction1);
junction1.To(junction2).Else();
junction2.To(activity3).Else();
activity3.To(end);
model.Validate();
var instance = new Instance("transitions");
model.Initialise(instance);
Trace.Assert(model.IsComplete(instance));
}
示例2: Run
public static void Run () {
var model = new StateMachine<Instance>("model");
var initial = new PseudoState<Instance>("initial", model);
var choice = new PseudoState<Instance>("choice", model, PseudoStateKind.Choice);
var junction = new PseudoState<Instance>("junction", model, PseudoStateKind.Junction);
var finalState = new FinalState<Instance>("final", model);
initial.To(choice);
choice.To(junction).When(i => i.Int1 == 0).Effect(i => i.Int1 = 1);
choice.To(finalState).Else();
junction.To(choice).When(i => i.Int2 == 0).Effect(i => i.Int2 = 2);
model.Validate();
var instance = new Instance("else");
model.Initialise(instance);
Trace.Assert(model.IsComplete(instance));
Trace.Assert(instance.Int1 == 1);
Trace.Assert(instance.Int2 == 2);
}
示例3: Run
public static void Run () {
var model = new StateMachine<Instance>("history");
var initial = new PseudoState<Instance>("initial", model, PseudoStateKind.Initial);
var shallow = new State<Instance>("shallow", model);
var deep = new State<Instance>("deep", model);
var end = new FinalState<Instance>("final", model);
var s1 = new State<Instance>("s1", shallow);
var s2 = new State<Instance>("s2", shallow);
initial.To(shallow);
new PseudoState<Instance>("shallow", shallow, PseudoStateKind.ShallowHistory).To(s1);
s1.To(s2).When<string>(c => c == "move");
shallow.To(deep).When<string>(c => c == "go deep");
deep.To(shallow).When<string>(c => c == "go shallow");
s2.To(end).When<string>(c => c == "end");
model.Validate();
var instance = new Instance("history");
model.Initialise(instance);
model.Evaluate(instance, "move");
model.Evaluate(instance, "go deep");
model.Evaluate(instance, "go shallow");
model.Evaluate(instance, "end");
Trace.Assert(model.IsComplete(instance));
}
示例4: Test
public static void Test()
{
var stateMachine = new StateMachine<State>( "external" );
var region = stateMachine.CreateRegion( "external" );
var initial = region.CreatePseudoState( "initial", PseudoStateKind.Initial );
var composite = region.CreateCompositeState( "composite" );
var orthogonal = region.CreateOrthogonalState( "orthogonal" );
var final = region.CreateFinalState( "final" );
var c1 = composite.CreateSimpleState( "c1" );
var c2 = composite.CreateSimpleState( "c2" );
var region1 = orthogonal.CreateRegion( "region1" );
var region2 = orthogonal.CreateRegion( "region2" );
var o1 = region1.CreateSimpleState( "o1" );
var o2 = region2.CreateSimpleState( "o2" );
var j1 = region2.CreatePseudoState( "junction", PseudoStateKind.Junction );
stateMachine.CreateTransition( initial, composite );
stateMachine.CreateTransition( composite.CreatePseudoState( "initial", PseudoStateKind.Initial ), c1 );
stateMachine.CreateTransition<String>( c2, c1, ( state, command ) => command == "1" );
stateMachine.CreateTransition<String>( c1, j1, ( state, command ) => command == "2" );
stateMachine.CreateElse( j1, o1 );
stateMachine.CreateTransition<String>( o1, o2, ( state, command ) => command == "3" );
stateMachine.CreateTransition<String>( o2, c2, ( state, command ) => command == "4" );
stateMachine.CreateTransition<String>( composite, orthogonal, ( state, command ) => command == "5" );
stateMachine.CreateTransition<String>( composite, final, ( state, command ) => command == "x" );
stateMachine.CreateTransition( region1.CreatePseudoState( "initial", PseudoStateKind.Initial ), o1 );
stateMachine.CreateTransition( region2.CreatePseudoState( "initial", PseudoStateKind.Initial ), o2 );
var instance = new State();
stateMachine.Initialise( instance );
Trace.Assert( !stateMachine.Process( instance, "1" ) );
Trace.Assert( stateMachine.Process( instance, "2" ) );
Trace.Assert( !stateMachine.Process( instance, "4" ) );
Trace.Assert( stateMachine.Process( instance, "3" ) );
Trace.Assert( stateMachine.Process( instance, "4" ) );
Trace.Assert( stateMachine.Process( instance, "1" ) );
Trace.Assert( !stateMachine.Process( instance, "z" ) );
Trace.Assert( stateMachine.Process( instance, "x" ) );
Trace.Assert( stateMachine.IsComplete( instance ) );
}
示例5: Run
public static void Run () {
var model = new StateMachine<Instance>("model");
var initial = new PseudoState<Instance>("initial", model, PseudoStateKind.Initial);
var ortho = new State<Instance>("ortho", model);
var simple = new State<Instance>("simple", model);
var final = new FinalState<Instance>("final", model);
var r1 = new Region<Instance>("r1", ortho);
var r2 = new Region<Instance>("r2", ortho);
var i1 = new PseudoState<Instance>("initial", r1, PseudoStateKind.ShallowHistory);
var i2 = new PseudoState<Instance>("initial", r2, PseudoStateKind.ShallowHistory);
var s1 = new State<Instance>("s1", r1);
var s2 = new State<Instance>("s2", r2);
var f1 = new FinalState<Instance>("f1", r1);
var f2 = new FinalState<Instance>("f2", r2);
initial.To(ortho);
i1.To(s1);
i2.To(s2);
ortho.To(final); // This should happen once all regions in ortho are complete?
s1.To(f1).When<string>(c => c == "complete1");
s2.To(f2).When<string>(c => c == "complete2");
ortho.To(simple).When<string>(c => c == "jump");
simple.To(ortho).When<string>(c => c == "back");
model.Validate();
var instance = new Instance("muximise");
model.Initialise(instance);
/*
console.log("simple.isSimple = " + simple.isSimple());
console.log("simple.isComposite = " + simple.isComposite());
console.log("simple.isOrthogonal = " + simple.isOrthogonal());
console.log("model.isSimple = " + model.isSimple());
console.log("model.isComposite = " + model.isComposite());
console.log("model.isOrthogonal = " + model.isOrthogonal());
console.log("ortho.isSimple = " + ortho.isSimple());
console.log("ortho.isComposite = " + ortho.isComposite());
console.log("ortho.isOrthogonal = " + ortho.isOrthogonal());
*/
Trace.Assert(simple.IsSimple);
Trace.Assert(!model.IsSimple);
Trace.Assert(!ortho.IsSimple);
Trace.Assert(!simple.IsComposite);
Trace.Assert(model.IsComposite);
Trace.Assert(ortho.IsComposite);
Trace.Assert(!simple.IsOrthogonal);
Trace.Assert(!model.IsOrthogonal);
Trace.Assert(ortho.IsOrthogonal);
model.Evaluate(instance, "complete1");
model.Evaluate(instance, "complete2");
Trace.Assert(model.IsComplete(instance));
}