Class DynamicParameter
OptimaJet.Workflow.Core.Model.DynamicParameter
Represents dynamically structured process parameter data as named properties that can be accessed by string key or through dynamic member binding.
Namespace: OptimaJet.Workflow.Core.Model
[JsonConverter(typeof(NewtonsoftDynamicParameterConverter))]
[JsonConverter(typeof(SystemTextDynamicParameterConverter))]
public sealed class DynamicParameter : DynamicObject, IDynamicMetaObjectProviderType Hierarchy
- DynamicObject
- DynamicParameter Current type
- Implemented interfaces
- DynamicParameter Current type
Attributes
Newtonsoft.Json.JsonConverterAttribute: Attribute of type Newtonsoft.Json.JsonConverterAttributeSystem.Text.Json.Serialization.JsonConverterAttribute: Attribute of type System.Text.Json.Serialization.JsonConverterAttribute
Constructors
public DynamicParameter() #Initializes an empty DynamicParameter with case-sensitive property-name comparisons.
public DynamicParameter(Dictionary<string, object> properties) #Initializes a DynamicParameter that uses the supplied properties as its backing storage.
Parameters
Name
Type
Description
propertiesDictionary<String, Object>The properties to store directly. The key comparer of the supplied Dictionary<TKey, TValue> controls property-name comparisons. Use null to create an empty instance with case-sensitive comparisons.
Properties
public IReadOnlyDictionary<string, object> Dictionary { get; } #Gets a read-only view of the stored properties.
public object this[string propertyName] { get; set; } #Gets or sets the value at a specified property path.
Exceptions
Type
Description
ExceptionWhen setting a value, an intermediate path segment exists but cannot be represented as a DynamicParameter.
Methods
public override bool TryGetMember(GetMemberBinder binder, out object result) #Gets a dynamic member value through DynamicParameter.GetProperty(string).
public override bool TrySetMember(SetMemberBinder binder, object value) #Sets a dynamic member value through DynamicParameter.SetProperty(string, object).
Parameters
Name
Type
Description
valueObjectThe value to store.
Returns
Type
Description
Booleantrue because the dynamic set operation is always handled.
public object GetProperty(string propertyName) #Gets the value at a specified property path.
Parameters
Name
Type
Description
propertyNameStringThe property name or period-delimited path.
Returns
Type
Description
ObjectThe stored value, or null if the path does not exist or cannot be traversed.
Example
After calling
parameter.SetProperty("Order.Customer.Name", "Alice"), parameter.GetProperty("Order.Customer.Name") returns "Alice", while parameter.GetProperty("Order.Customer.Id") returns null.public void SetProperty(string propertyName, object value) #Sets the value at a specified property path, creating missing nested DynamicParameter instances.
Parameters
Name
Type
Description
propertyNameStringThe property name or period-delimited path.
valueObjectThe value to store.
Exceptions
Type
Description
ExceptionAn intermediate path segment exists but cannot be represented as a DynamicParameter.
Example
parameter.SetProperty("Order.Customer.Name", "Alice") creates the missing Order and Customer objects and stores "Alice" at the specified path. A subsequent call to parameter.GetProperty("Order.Customer.Name") returns "Alice".public bool HasProperty(string propertyName, bool ifNullThenNotExists = false) #Determines whether a specified property path exists.
Parameters
Name
Type
Description
propertyNameStringThe property name or period-delimited path.
Returns
public DynamicParameter DeepClone() #Creates an independent copy of this DynamicParameter through JSON serialization.
Returns
Type
Description
DynamicParameterA new DynamicParameter containing the serialized property values.
public string SerializeToJson() #Serializes the stored properties to JSON.
Returns
Type
Description
StringThe JSON representation of the stored properties.
public static object ParseJson(string json) #Parses JSON text into the runtime representation used by DynamicParameter.
Parameters
Name
Type
Description
jsonStringThe JSON text to parse.
Returns
Type
Description
ObjectA scalar or collection value for a corresponding JSON value; a DynamicParameter for a JSON object; null for empty input or a JSON null value; or the original text if it is not valid JSON.
public static object ParseJson(JToken jToken) #Converts a JToken into the runtime representation used by DynamicParameter.
Parameters
Name
Type
Description
jTokenJTokenThe JSON token to convert.
Returns
Type
Description
ObjectA scalar or collection value for a corresponding JSON value; a DynamicParameter for a JSON object; or null if
jToken is null or represents a JSON null value.public static dynamic New() #Creates an empty DynamicParameter exposed through dynamic binding.
Returns
Type
Description
dynamicA new empty DynamicParameter returned as dynamic.
public static object ConvertFrom(object value) #Converts an object graph to the representation used by DynamicParameter.
Parameters
Name
Type
Description
valueObjectThe value to convert.
Returns
Type
Description
ObjectExceptions
Type
Description
ExceptionThe object graph cannot be converted or exceeds the supported conversion depth.
Remarks
A value that implements IDynamicParameterCompatible supplies its properties through IDynamicParameterCompatible.GetPropertiesAsDictionary().
public T ConvertTo<T>() where T : IDynamicParameterCompatible, new() #Creates and populates an IDynamicParameterCompatible object from the stored properties.
Returns
Type
Description
{T}A new
T populated from the stored properties.public T Restore<T>() #Restores the stored properties as
T.Returns
Type
Description
{T}The restored
T value.Exceptions
Type
Description
ExceptionT implements IDynamicParameterCompatible, but an instance cannot be created or populated.Remarks
This overload delegates to DynamicParameter.Restore(Type).
public object Restore(Type originalType) #Restores the stored properties as an object of a specified type.
Parameters
Name
Type
Description
Returns
Type
Description
ObjectThe restored value.
Exceptions
Type
Description
ExceptionoriginalType implements IDynamicParameterCompatible, but an instance cannot be created or populated.Remarks
A DynamicParameter target returns this instance. A target type that implements IDictionary<string, object> returns a serializable property dictionary. A target type that implements IDynamicParameterCompatible is instantiated and populated through IDynamicParameterCompatible.SetPropertiesFromDictionary(IDictionary<string, object>); all other target types are restored through JSON deserialization.
Remarks
DynamicParameter.GetProperty(string), DynamicParameter.SetProperty(string, object), and DynamicParameter.HasProperty(string, bool) accept period-delimited paths for nested properties.