/// <summary> /// 创建一个状态. /// </summary> /// <param name="name">状态的名称.</param> /// <param name="startActions">地址跳转行为.</param> /// <param name="completedActions">状态完成后的行为.</param> /// <param name="completedStateSetting">状态完成后会转到的状态的名称.</param> /// <param name="failedActions">状态失败后的行为.</param> /// <param name="failedStateSetting">状态失败后会转到的状态的名称.</param> /// <param name="conditions">成此状态的条件.</param> /// <param name="timeout">超时秒数.</param> public FlowState(string name, A[] startActions, A[] completedActions, NextStateSetting <A, C> completedStateSetting, A[] failedActions, NextStateSetting <A, C> failedStateSetting, C[] conditions, int timeout) #endif { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name", "状态的名称不能为空"); } if (null != startActions) { foreach (A action in startActions) { if (null != action) { this.StartActions.Add(action); } } } if (null != completedActions) { foreach (A action in completedActions) { if (null != action) { this.CompletedActions.Add(action); } } } if (null != failedActions) { foreach (A action in failedActions) { if (null != action) { this.FailedActions.Add(action); } } } if (null != conditions) { foreach (C condition in conditions) { if (null != condition) { this.Conditions.Add(condition, false); } } } if (timeout < 0) { timeout = 0; } this.Name = name; this.CompletedStateSetting = completedStateSetting; this.FailedStateSetting = failedStateSetting; this.Timeout = timeout; }
/// <summary> /// 创建一个状态. /// </summary> /// <param name="name">状态的名称.</param> /// <param name="startAction">地址跳转行为.</param> /// <param name="completedAction">状态完成后的行为.</param> /// <param name="completedStateSetting">状态完成后会转到的状态的名称.</param> /// <param name="failedAction">状态失败后的行为.</param> /// <param name="failedStateSetting">状态失败后会转到的状态的名称.</param> /// <param name="condition">成此状态的条件.</param> /// <param name="timeout">超时秒数.</param> public FlowState(string name, A startAction, A completedAction, NextStateSetting <A, C> completedStateSetting, A failedAction, NextStateSetting <A, C> failedStateSetting, C condition, int timeout) #endif : this(name, new A[] { startAction }, new A[] { completedAction }, completedStateSetting, new A[] { failedAction }, failedStateSetting, new C[] { condition }, timeout) { }
/// <summary> /// 创建一个状态. /// </summary> /// <param name="name">状态的名称.</param> /// <param name="startActions">地址跳转行为.</param> /// <param name="completedActions">状态完成后的行为.</param> /// <param name="completedStateSetting">状态完成后会转到的状态的名称.</param> /// <param name="failedActions">状态失败后的行为.</param> /// <param name="failedStateSetting">状态失败后会转到的状态的名称.</param> /// <param name="conditions">成此状态的条件.</param> /// <param name="timeout">超时秒数.</param> public FlowState(string name, A[] startActions = null, A[] completedActions = null, NextStateSetting <A, C> completedStateSetting = null, A[] failedActions = null, NextStateSetting <A, C> failedStateSetting = null, C[] conditions = null, int timeout = 0)
/// <summary> /// 创建一个状态. /// </summary> /// <param name="name">状态的名称.</param> /// <param name="startActions">地址跳转行为.</param> /// <param name="completedAction">状态完成后的行为.</param> /// <param name="completedStateSetting">状态完成后会转到的状态的名称.</param> /// <param name="failedAction">状态失败后的行为.</param> /// <param name="failedStateSetting">状态失败后会转到的状态的名称.</param> /// <param name="condition">成此状态的条件.</param> /// <param name="timeout">超时秒数.</param> public FlowState(string name, A[] startActions = null, A completedAction = null, NextStateSetting <A, C> completedStateSetting = null, A failedAction = null, NextStateSetting <A, C> failedStateSetting = null, C condition = null, int timeout = 0) : this(name, startActions, new A[] { completedAction }, completedStateSetting, new A[] { failedAction }, failedStateSetting, new C[] { condition }, timeout) { }