Documentation
Table of Contents

Class IntentScope

Namespace
IntentSharp.Catalog
Assembly
IntentSharp.Catalog.dll

Makes an IntentRuntime ambient for the current async flow, so values can run catalog intents by name without passing the runtime:

using var scope = runtime.AsAmbient();
var urgency = await email.RunIntentAsync<int>("Orders.ClassifyUrgency");

Like IntentClientScope, this is AsyncLocal<T> state: it flows with awaits and tasks started inside it, is invisible to other requests and threads, nests (the inner scope wins until it is disposed) and ends when disposed. A task started inside the scope that is still running after the scope was disposed no longer sees the runtime. There is no process-wide default runtime.

public sealed class IntentScope : IDisposable
Inheritance
object
IntentScope
Implements
IDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Extension Methods

Properties

Current

The ambient runtime. Throws with guidance when no scope is active.

CurrentOrNull

The ambient runtime, or null when no scope is active on this async flow.

Methods

Dispose()

Ends the scope, and with it every scope opened inside it on this flow: the runtime that was ambient before this scope opened becomes ambient again. A scope that an enclosing scope already ended (because the enclosing scope was disposed first) changes nothing, so a runtime whose scope has ended never becomes ambient again. Disposing twice is a no-op. Current and CurrentOrNull skip ended scopes on every flow, including flows this call does not run on.