# Class ParametersCollection OptimaJet.Workflow.Core.Model.ParametersCollection Represents the collection of process parameters owned by a [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). Namespace: [OptimaJet.Workflow.Core.Model](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/) ```csharp public sealed class ParametersCollection : IEnumerable, IEnumerable ``` ## Type Hierarchy - ParametersCollection Current type - Implemented interfaces - [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable) - [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1) ## Constructors `public ParametersCollection(List parameters, ProcessInstance owner)` Initializes a new instance of the [ParametersCollection](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParametersCollection/) class with `parameters`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameters` | `List` | The [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/) objects to store in the collection. | | `owner` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) that owns the process parameters. | ### Exceptions | Type | Description | | --- | --- | | `ArgumentNullException` | `parameters` or `owner` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | `public ParametersCollection(IEnumerable parameters, ProcessInstance owner)` Initializes a new instance of the [ParametersCollection](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParametersCollection/) class by copying `parameters`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameters` | `IEnumerable` | The sequence of [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/) objects used to populate the collection. | | `owner` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) that owns the process parameters. | ### Exceptions | Type | Description | | --- | --- | | `ArgumentNullException` | `parameters` or `owner` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | `public ParametersCollection(ProcessInstance owner)` Initializes an empty instance of the [ParametersCollection](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParametersCollection/) class. ### Parameters | Name | Type | Description | | --- | --- | --- | | `owner` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) that owns the process parameters. | ### Exceptions | Type | Description | | --- | --- | | `ArgumentNullException` | `owner` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | ## Methods `public IEnumerator GetEnumerator()` ### Returns | Type | Description | | --- | --- | | `IEnumerator` | | `public void AddParameter(ParameterDefinitionWithValue parameter)` Adds `parameter`, replacing any parameters with the same parameter name. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameter` | `ParameterDefinitionWithValue` | The [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/) to add. | `public void AddParameters(IEnumerable parameters)` Adds `parameters`, replacing current parameters with matching parameter names. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameters` | `IEnumerable` | The [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/) objects to add. | `public void ReplaceParameters(List parameters)` Replaces the process parameters in the collection with `parameters`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameters` | `List` | The [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/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](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) value. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The parameter name or dot-separated path to a nested property. | ### Returns | Type | Description | | --- | --- | | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the parameter or nested property has a non-[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) value; otherwise, [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | `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](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/), or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if no parameter is found or a nested value is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | `public Task 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` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) whose result is the matching [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/), or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if no parameter is found or a nested value is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | `public T GetParameter(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](https://learn.microsoft.com/dotnet/api/system.string) and the result is not [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), reading a process parameter whose [ParameterDefinition.Purpose](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinition/) is [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) and whose [ParameterDefinitionWithValue.IsImplicit](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/) is [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) marks the containing [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/) as modified. ### Example If the `Order` parameter contains a nested `Customer.Name` property, `parameters.GetParameter("Order.Customer.Name")` returns that property's value. `public Task GetParameterAsync(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` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) 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](https://learn.microsoft.com/dotnet/api/system.string) and the result is not [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), reading a process parameter whose [ParameterDefinition.Purpose](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinition/) is [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) and whose [ParameterDefinitionWithValue.IsImplicit](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/) is [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) marks the containing [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/) as modified. ### Example If the `Order` parameter contains a nested `Customer.Name` property, `await parameters.GetParameterAsync("Order.Customer.Name")` returns that property's value. `public void SetParameter(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](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) assigned to a missing implicit parameter. When `purposeIfMissing` is [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/), a missing explicit parameter defined in [ProcessDefinition.Parameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) 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(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](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) assigned to a missing implicit parameter. When `purposeIfMissing` is [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/), a missing explicit parameter defined in [ProcessDefinition.Parameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) is also created as a persistent parameter. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.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](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/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](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), or removes the top-level parameter from the collection when `removeFromCollection` is [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). ### 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](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | | `removeFromCollection` | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to remove the top-level [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/) from the collection; [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to set the parameter or nested property value to [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | `public void InitPersistenceParametersFromScheme()` Initializes process parameters from non-[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) [ParameterDefinition.InitialValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinition/) values for definitions in [ProcessDefinition.Parameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) whose [ParameterDefinition.Purpose](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinition/) is [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/). ### Exceptions | Type | Description | | --- | --- | | `InvalidJsonParameterValueException` | A persistent parameter other than [string](https://learn.microsoft.com/dotnet/api/system.string) has a [ParameterDefinition.InitialValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinition/) that cannot be deserialized from JSON. | [Previous ParameterPurpose](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) [Next ParameterType](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterType/)