protected void OnEntryBehavior() { try { _logger.Debug($"{_context}: State '{Name}' performing ENTRY behavior."); _entryBehavior?.Invoke(RuntimeContainer); } catch (Exception ex) { _logger.Error($"{_context}: {ex.GetType().Name} during ENTRY behavior in State '{Name}'.", ex); } }
protected void OnExitBehavior() { //TODO: remove try/catch here since Behavior now does it. try { _logger.Debug($"{_context}: State '{Name}' performing EXIT behavior."); _exitBehavior?.Invoke(RuntimeContainer); } catch (Exception ex) { _logger.Error($"{_context}: {ex.GetType().Name} during EXIT behavior in State '{Name}'.", ex); } }
protected void Invoke(IBehavior behavior) { var verbAttrs = behavior.GetType().GetTypeInfo().GetCustomAttribute(typeof(VerbAttribute)) as VerbAttribute; if (verbAttrs == null || verbAttrs.Verb.HasFlag(Verb)) { //string text = middleware.Text; //身份验证 Authentic(behavior); behavior.Invoke().Wait(); return; } //Assert.W("该中间件不支持相应谓词操作"); throw new NotFoundException("该中间件不支持相应谓词操作"); }
private void OnDoBehavior(IBehavior doBehavior) { // State changes don't need to wait for all the DO behaviors to finish. if (!IsCurrentState) { _logger.Debug($"{_context}: State '{Name}' DO behavior ignored because {Name} is no longer the current state."); return; } if (doBehavior != null) { doBehavior.Invoke(RuntimeContainer); if (doBehavior.Fault != null) { _logger.Error($"{_context}: {doBehavior.Fault.GetType().Name} during DO behavior in state '{Name}'.", doBehavior.Fault); } } }
/// <summary> /// <see cref="Ricordanza.Core.Behaviors.IBehavior"/>を実行します。 /// </summary> /// <param name="behavior">実行したい<see cref="Ricordanza.Core.Behaviors.IBehavior"/></param> public static void Execute(IBehavior behavior) { if (behavior == null) return; try { // 初期化処理の実行 behavior.Initalize(); // メイン処理の実行 behavior.Invoke(); } finally { // 終了処理の実行 behavior.Terminate(); } }