Add named WithVariable overload (#7701)
This commit is contained in:
parent
50ef957031
commit
fb4fb63c3a
|
|
@ -88,6 +88,14 @@ public class WorkflowBuilder(IActivityVisitor activityVisitor, IIdentityGraphSer
|
|||
return variable;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Variable<T> WithVariable<T>(string name)
|
||||
{
|
||||
var variable = new Variable<T>(name, default!);
|
||||
Variables.Add(variable);
|
||||
return variable;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Variable<T> WithVariable<T>(string name, T value)
|
||||
{
|
||||
|
|
@ -298,4 +306,4 @@ public class WorkflowBuilder(IActivityVisitor activityVisitor, IIdentityGraphSer
|
|||
await workflowDefinition.BuildAsync(this, cancellationToken);
|
||||
return await BuildWorkflowAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,6 +115,11 @@ public interface IWorkflowBuilder
|
|||
[Obsolete("Use the overload that takes a name instead. This overload will be removed in a future version.")]
|
||||
Variable<T> WithVariable<T>();
|
||||
|
||||
/// <summary>
|
||||
/// A fluent method for adding a variable to <see cref="Variables"/>.
|
||||
/// </summary>
|
||||
Variable<T> WithVariable<T>(string name);
|
||||
|
||||
/// <summary>
|
||||
/// A fluent method for adding a variable to <see cref="Variables"/>.
|
||||
/// </summary>
|
||||
|
|
@ -220,4 +225,4 @@ public interface IWorkflowBuilder
|
|||
/// Creates a new <see cref="Workflow"/> instance using the specified <see cref="IWorkflow"/> definition.
|
||||
/// </summary>
|
||||
Task<Workflow> BuildWorkflowAsync(IWorkflow workflowDefinition, CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class SampleWorkflow : WorkflowBase
|
|||
{
|
||||
protected override void Build(IWorkflowBuilder workflow)
|
||||
{
|
||||
var variable1 = workflow.WithVariable("Some variable");
|
||||
var variable1 = workflow.WithVariable<string>("Some variable");
|
||||
var variable2 = workflow.WithVariable(42);
|
||||
var literal1 = new Literal<string>("Some literal");
|
||||
var literal2 = new Literal<int>(84);
|
||||
|
|
@ -27,4 +27,4 @@ class SampleWorkflow : WorkflowBase
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue