当前位置: 首页>>代码示例>>C#>>正文


C# Instance.GetCurrent方法代码示例

本文整理汇总了C#中Instance.GetCurrent方法的典型用法代码示例。如果您正苦于以下问题:C# Instance.GetCurrent方法的具体用法?C# Instance.GetCurrent怎么用?C# Instance.GetCurrent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Instance的用法示例。


在下文中一共展示了Instance.GetCurrent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

		public static void Run () {
			var model = new StateMachine<Instance>("model");
			var initial = new PseudoState<Instance>("initial", model, PseudoStateKind.Initial);
			var target = new State<Instance>("state", model).Entry(i => i.Int1++).Exit(i => i.Int2++);

			initial.To(target);

			target.To().When<string>(m => m == "internal").Effect(i => i.Int3++);
			target.To(target).When<string>(m => m == "external").Effect(i => i.Int3++);

			var instance = new Instance("internal");

			model.Validate();

			model.Initialise(instance);

			model.Evaluate(instance, "internal");

			Trace.Assert(target == instance.GetCurrent(model.DefaultRegion));
			Trace.Assert(1 == instance.Int1);
			Trace.Assert(0 == instance.Int2);
			Trace.Assert(1 == instance.Int3);

			model.Evaluate(instance, "external");

			Trace.Assert(target == instance.GetCurrent(model.DefaultRegion));
			Trace.Assert(2 == instance.Int1);
			Trace.Assert(1 == instance.Int2);
			Trace.Assert(2 == instance.Int3);
		}
开发者ID:steelbreeze,项目名称:state.cs,代码行数:30,代码来源:Internal.cs

示例2: Run

		public static void Run () {

			var model = new StateMachine<Instance>("model");
			var initial = new PseudoState<Instance>("initial", model, PseudoStateKind.Initial);
			var junction1 = new PseudoState<Instance>("junction1", model, PseudoStateKind.Junction);
			var junction2 = new PseudoState<Instance>("junction2", model, PseudoStateKind.Junction);

			var pass = new State<Instance>("success", model);
			var fail = new State<Instance>("error", model);

			initial.To(junction1);

			junction1.To(junction2).When(i => i.Int1 == 0).Effect(i => i.Int1++);
			junction1.To(fail).Else();
			junction2.To(pass).When(i => i.Int1 == 0).Effect(i => i.Int1++);
			junction2.To(fail).Else();

			model.Validate();

			var instance = new Instance("static");

			model.Initialise(instance);

			Trace.Assert(pass == instance.GetCurrent(model.DefaultRegion));

			Trace.Assert(2 == instance.Int1);
		}
开发者ID:steelbreeze,项目名称:state.cs,代码行数:27,代码来源:Static.cs

示例3: Run

		public static void Run () {
			var model = new StateMachine<Instance>("model");
			var initial = new PseudoState<Instance>("initial", model, PseudoStateKind.Initial);
			var state1 = new State<Instance>("state1", model);
			var state2 = new State<Instance>("state2", model);

			var regionA = new Region<Instance>("regionA", state1);
			var initialA = new PseudoState<Instance>("initialA", regionA, PseudoStateKind.Initial);
			var state3 = new State<Instance>("state3", regionA);
			var state8 = new State<Instance>("state8", regionA);

			var regionB = new Region<Instance>("regionB", state1);
			var initialB = new PseudoState<Instance>("initialB", regionB, PseudoStateKind.Initial);
			var state4 = new State<Instance>("state4", regionB);
			var state5 = new State<Instance>("state5", regionB);

			var regionBa = new Region<Instance>("regionBa", state4);
			var initialBa = new PseudoState<Instance>("initialBa", regionBa, PseudoStateKind.Initial);
			var state6 = new State<Instance>("state6", regionBa);

			var regionBb = new Region<Instance>("regionBb", state4);
			var initialBb = new PseudoState<Instance>("initialBb", regionBb, PseudoStateKind.Initial);
			var state7 = new State<Instance>("state7", regionBb);

			initial.To(state1);
			initialA.To(state3);
			initialB.To(state4);
			initialBa.To(state6);
			initialBb.To(state7);

			state3.To(state2).When<string>(c => c == "event2");
			state3.To(state8).When<string>(c => c == "event1");
			state7.To(state5).When<string>(c => c == "event2");
			state7.To(state5).When<string>(c => c == "event1");

			model.Validate();

			var instance = new Instance("p3pp3r");
			model.Initialise(instance);

			model.Evaluate(instance, "event2");

			Trace.Assert(state2 == instance.GetCurrent(model.DefaultRegion), instance.GetCurrent(model.DefaultRegion).ToString() );
			Trace.Assert(state4 == instance.GetCurrent(regionB));
		}
开发者ID:steelbreeze,项目名称:state.cs,代码行数:45,代码来源:p3pp3r.cs

示例4: Run

		public static void Run () {

			var model = new StateMachine<Instance>("model");
			var initial1 = new PseudoState<Instance>("initial", model, PseudoStateKind.Initial);
			var myComposite1 = new State<Instance>("composite1", model);
			var state3 = new State<Instance>("state3", model);
			var initial2 = new PseudoState<Instance>("initial", myComposite1, PseudoStateKind.Initial);
			var state1 = new State<Instance>("state1", myComposite1);
			var state2 = new State<Instance>("state2", myComposite1);

			initial1.To(myComposite1);
			initial2.To(state1);
			myComposite1.To(state3).When<string>(c => c == "a");
			state1.To(state2).When<string>(c => c == "a");

			model.Validate();

			var instance = new Instance("brice");
			model.Initialise(instance);

			model.Evaluate(instance, "a");

			Trace.Assert(instance.GetCurrent(myComposite1.DefaultRegion) == state2);
		}
开发者ID:steelbreeze,项目名称:state.cs,代码行数:24,代码来源:Brice.cs


注:本文中的Instance.GetCurrent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。