C# - No DI - so how to pass IOptions into WF?

Since workflows need to be deterministic, you usually would not have something specific to a certain machine. The common way to do this is to either pass this information in via workflow input (e.g. add a serializable field on your existing workflow parameter record ) or create a local activity that returns a serializable form of this information back to the workflow. Both ways will make sure your workflow has this options/config in history and not subject to mutations/differences later or on different machines.

If just the activities need this DI’d data, no need for it to flow through the workflow, activities support DI (see here). But if workflows need it, can’t DI (it’s unsafe), have to use one of the two approaches mentioned above.

(pasted answer from Slack, did not see this question in forums first, just added dotnet-sdk tag)

1 Like