Class ParametersCollection
OptimaJet.Workflow.Core.Model.ParametersCollection
Represents the collection of process parameters owned by a ProcessInstance.
Namespace: OptimaJet.Workflow.Core.Model
public sealed class ParametersCollection : IEnumerable<ParameterDefinitionWithValue>, IEnumerableType Hierarchy
- ParametersCollection Current type
- Implemented interfaces
Constructors
public ParametersCollection(List<ParameterDefinitionWithValue> parameters, ProcessInstance owner) #Initializes a new instance of the ParametersCollection class with
parameters.Parameters
Name
Type
Description
parametersList<ParameterDefinitionWithValue>The ParameterDefinitionWithValue objects to store in the collection.
Exceptions
Type
Description
ArgumentNullExceptionpublic ParametersCollection(IEnumerable<ParameterDefinitionWithValue> parameters, ProcessInstance owner) #Initializes a new instance of the ParametersCollection class by copying
parameters.Parameters
Name
Type
Description
parametersIEnumerable<ParameterDefinitionWithValue>The sequence of ParameterDefinitionWithValue objects used to populate the collection.
Exceptions
Type
Description
ArgumentNullExceptionpublic ParametersCollection(ProcessInstance owner) #Initializes an empty instance of the ParametersCollection class.
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
public void AddParameters(IEnumerable<ParameterDefinitionWithValue> parameters) #Adds
parameters, replacing current parameters with matching parameter names.Parameters
Name
Type
Description
public void ReplaceParameters(List<ParameterDefinitionWithValue> parameters) #Replaces the process parameters in the collection with
parameters.Parameters
Name
Type
Description
parametersList<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.public ParameterDefinitionWithValue GetParameter(string name) #Gets the parameter or nested parameter property identified by
name.Parameters
Name
Type
Description
nameStringThe parameter name or dot-separated path to a nested property.
Returns
Type
Description
ParameterDefinitionWithValueThe 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
nameStringThe 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
nameStringThe 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
nameStringThe parameter name or dot-separated path to a nested property.
Returns
Type
Description
Task<T>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
nameStringThe parameter name or dot-separated path to a nested property.
value{T}The value to assign.
purposeIfMissingParameterPurposeThe 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
nameStringThe parameter name or dot-separated path to a nested property.
value{T}The value to assign.
purposeIfMissingParameterPurposeThe 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
TaskA 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
nameStringThe name of the implicit parameter.
valueStringThe JSON-serialized parameter value.
purposeIfMissingParameterPurposeThe 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
nameStringThe parameter name or dot-separated path to a nested property. A path is supported only when
removeFromCollection is false.removeFromCollectionBooleantrue 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
InvalidJsonParameterValueExceptionA persistent parameter other than string has a ParameterDefinition.InitialValue that cannot be deserialized from JSON.