本文整理汇总了C#中StateMachine.ResetTo方法的典型用法代码示例。如果您正苦于以下问题:C# StateMachine.ResetTo方法的具体用法?C# StateMachine.ResetTo怎么用?C# StateMachine.ResetTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateMachine
的用法示例。
在下文中一共展示了StateMachine.ResetTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public static StateMachine<CreditRequest> Create(CreditRequest request)
{
var provider = new ScanningStateProvider<CreditRequest>();
var config = new MachineConfiguration<CreditRequest>();
config.OnStateChange(
reset: (sender, args) => args.Switches.State = args.Next.GetType(),
enter: (sender, args) => args.Switches.State = args.Next.GetType()
);
var machine = new StateMachine<CreditRequest>(config, provider, request);
machine.ResetTo(request.State);
return machine;
}
示例2: When_finding_custom_states
public void When_finding_custom_states()
{
var scanner = new ScanningStateProvider<CreditRequest>();
var provider = new MappingStateProvider(scanner);
var config = new MachineConfiguration<CreditRequest>();
config.OnStateChange(
reset: (sender, args) => args.Switches.Progress = ((CustomState<CreditRequest>)args.Next).Type,
enter: (sender, args) => args.Switches.Progress = ((CustomState<CreditRequest>)args.Next).Type
);
var request = LoadFromDatabase();
var machine = new StateMachine<CreditRequest>(provider, request);
machine.ResetTo(provider.StateFrom(request.Progress).GetType());
machine.CurrentState.ShouldBeOfType<Approved>();
}