public static async ValueTask <Behavior <T> > Interpret <T>(Behavior <T> behavior, IActorContext <T> context, T message) { if (behavior is ExtensibleBehavior <T> ext) { var result = await ext.Receive(context, message); return(await Unwrap(result, context)); } else if (behavior is StoppedBehavior <T> || behavior is FailedBehavior <T> ) { return(behavior); } else if (behavior is IgnoreBehavior <T> ) { return(Same <T>()); } else if (behavior is EmptyBehavior <T> ) { return(Unhandled <T>()); } else { Raises.InvalidArgument($"Cannot execute behavior of type [{behavior?.GetType()}] using interpreter"); return(default);
public StoppedBehavior(Behavior <T> postStop) { if (postStop is DeferredBehavior <T> ) { Raises.InvalidArgument("Behavior used as `postStop` behavior in Stopped(...) was a deferred one, which is not supported (it would never be evaluated)."); } PostStop = postStop; }