Assembly: OptimaJet.Workflow.Core

Class ParametersCollection

OptimaJet.Workflow.Core.Model.ParametersCollection

Represents the collection of process parameters owned by a ProcessInstance.

public sealed class ParametersCollection : IEnumerable<ParameterDefinitionWithValue>, IEnumerable

Type Hierarchy

Constructors

public ParametersCollection(List<ParameterDefinitionWithValue> parameters, ProcessInstance owner) #
Initializes a new instance of the ParametersCollection class with parameters.

Parameters

Name
Type
Description
parameters
List<ParameterDefinitionWithValue>
The ParameterDefinitionWithValue objects to store in the collection.
owner
ProcessInstance
The ProcessInstance that owns the process parameters.

Exceptions

Type
Description
ArgumentNullException
parameters or owner is null.
public ParametersCollection(IEnumerable<ParameterDefinitionWithValue> parameters, ProcessInstance owner) #
Initializes a new instance of the ParametersCollection class by copying parameters.

Parameters

Name
Type
Description
parameters
IEnumerable<ParameterDefinitionWithValue>
The sequence of ParameterDefinitionWithValue objects used to populate the collection.
owner
ProcessInstance
The ProcessInstance that owns the process parameters.

Exceptions

Type
Description
ArgumentNullException
parameters or owner is null.
public ParametersCollection(ProcessInstance owner) #
Initializes an empty instance of the ParametersCollection class.

Parameters

Name
Type
Description
owner
ProcessInstance
The ProcessInstance that owns the process parameters.

Exceptions

Type
Description
ArgumentNullException
owner is null.

Methods

public IEnumerator<ParameterDefinitionWithValue> GetEnumerator() #

Returns

Type
Description
IEnumerator<ParameterDefinitionWithValue>
public void AddParameter(ParameterDefinitionWithValue parameter) #
Adds parameter, replacing any parameters with the same parameter name.

Parameters

Name
Type
Description
parameter
ParameterDefinitionWithValue
public void AddParameters(IEnumerable<ParameterDefinitionWithValue> parameters) #
Adds parameters, replacing current parameters with matching parameter names.

Parameters

Name
Type
Description
parameters
IEnumerable<ParameterDefinitionWithValue>
The ParameterDefinitionWithValue objects to add.
public void ReplaceParameters(List<ParameterDefinitionWithValue> parameters) #
Replaces the process parameters in the collection with parameters.

Parameters

Name
Type
Description
parameters
List<ParameterDefinitionWithValue>
The ParameterDefinitionWithValue objects that become the collection contents.
public bool IsParameterExisting(string name) #
Determines whether the collection contains a process parameter or nested property identified by name with a non-null value.

Parameters

Name
Type
Description
name
String
The parameter name or dot-separated path to a nested property.

Returns

Type
Description
Boolean
true if the parameter or nested property has a non-null value; otherwise, false.
public ParameterDefinitionWithValue GetParameter(string name) #
Gets the parameter or nested parameter property identified by name.

Parameters

Name
Type
Description
name
String
The parameter name or dot-separated path to a nested property.

Returns

Type
Description
ParameterDefinitionWithValue
The matching ParameterDefinitionWithValue, or null if no parameter is found or a nested value is null.
public Task<ParameterDefinitionWithValue> GetParameterAsync(string name) #
Asynchronously gets the parameter or nested parameter property identified by name.

Parameters

Name
Type
Description
name
String
The parameter name or dot-separated path to a nested property.

Returns

Type
Description
Task<ParameterDefinitionWithValue>
A Task<TResult> whose result is the matching ParameterDefinitionWithValue, or null if no parameter is found or a nested value is null.
public T GetParameter<T>(string name) #
Gets the value of the parameter or nested parameter property identified by name.

Parameters

Name
Type
Description
name
String
The parameter name or dot-separated path to a nested property.

Returns

Type
Description
{T}
The value as T, or the default value of T if no value is found.

Remarks

When T is a reference type other than string and the result is not null, reading a process parameter whose ParameterDefinition.Purpose is ParameterPurpose.Persistence and whose ParameterDefinitionWithValue.IsImplicit is false marks the containing ParameterDefinitionWithValue as modified.

Example

If the Order parameter contains a nested Customer.Name property, parameters.GetParameter<string>("Order.Customer.Name") returns that property's value.
public Task<T> GetParameterAsync<T>(string name) #
Asynchronously gets the value of the parameter or nested parameter property identified by name.

Parameters

Name
Type
Description
name
String
The parameter name or dot-separated path to a nested property.

Returns

Type
Description
Task<T>
A Task<TResult> whose result is the value as T, or the default value of T if no value is found.

Remarks

When T is a reference type other than string and the result is not null, reading a process parameter whose ParameterDefinition.Purpose is ParameterPurpose.Persistence and whose ParameterDefinitionWithValue.IsImplicit is false marks the containing ParameterDefinitionWithValue as modified.

Example

If the Order parameter contains a nested Customer.Name property, await parameters.GetParameterAsync<string>("Order.Customer.Name") returns that property's value.
public void SetParameter<T>(string name, T value, ParameterPurpose purposeIfMissing = ParameterPurpose.Temporary) #
Sets the value of the parameter or nested parameter property identified by name.

Parameters

Name
Type
Description
name
String
The parameter name or dot-separated path to a nested property.
value
{T}
The value to assign.
purposeIfMissing
ParameterPurpose
The ParameterPurpose assigned to a missing implicit parameter. When purposeIfMissing is ParameterPurpose.Persistence, a missing explicit parameter defined in ProcessDefinition.Parameters is also created as a persistent parameter.

Example

parameters.SetParameter("Order.Customer.Name", "Alice") assigns "Alice" to the nested Name property of Customer in the Order parameter.
public Task SetParameterAsync<T>(string name, T value, ParameterPurpose purposeIfMissing = ParameterPurpose.Temporary) #
Asynchronously sets the value of the parameter or nested parameter property identified by name.

Parameters

Name
Type
Description
name
String
The parameter name or dot-separated path to a nested property.
value
{T}
The value to assign.
purposeIfMissing
ParameterPurpose
The ParameterPurpose assigned to a missing implicit parameter. When purposeIfMissing is ParameterPurpose.Persistence, a missing explicit parameter defined in ProcessDefinition.Parameters is also created as a persistent parameter.

Returns

Type
Description
Task
A Task that represents the asynchronous operation.

Example

await parameters.SetParameterAsync("Order.Customer.Name", "Alice") assigns "Alice" to the nested Name property of Customer in the Order parameter.
public void SetImplicitSerializedParameter(string name, string value, ParameterPurpose purposeIfMissing = ParameterPurpose.Temporary) #
Sets the implicit process parameter identified by name from the JSON-serialized value in value.

Parameters

Name
Type
Description
name
String
The name of the implicit parameter.
value
String
The JSON-serialized parameter value.
purposeIfMissing
ParameterPurpose
The ParameterPurpose to assign if the implicit parameter must be created.
public void RemoveParameter(string name, bool removeFromCollection = false) #
Sets the process parameter or nested property identified by name to null, or removes the top-level parameter from the collection when removeFromCollection is true.

Parameters

Name
Type
Description
name
String
The parameter name or dot-separated path to a nested property. A path is supported only when removeFromCollection is false.
removeFromCollection
Boolean
true to remove the top-level ParameterDefinitionWithValue from the collection; false to set the parameter or nested property value to null.
public void InitPersistenceParametersFromScheme() #
Initializes process parameters from non-null ParameterDefinition.InitialValue values for definitions in ProcessDefinition.Parameters whose ParameterDefinition.Purpose is ParameterPurpose.Persistence.

Exceptions

Type
Description
InvalidJsonParameterValueException
A persistent parameter other than string has a ParameterDefinition.InitialValue that cannot be deserialized from JSON.