Class MergePatchOperation
- Namespace
- Homa.Sdk.Configuration
- Assembly
- Homa.Sdk.Configuration.dll
Represents a patch operation that merges a value into a config property or the whole config.
public class MergePatchOperation : IPatchOperation
- Inheritance
-
MergePatchOperation
- Implements
- Inherited Members
Examples
An example of intended Merge Operation application order: Given a config:
{ a: { x: 0 } }
Patch A, Priority 2 (highest priority)
- Merge operation, path:
acontent:{ x: 1, y: 0 } - Merge operation, path:
a.bcontent:4
Patch B, Priority 1
- Merge operation, path:
a.ycontent:2
After applying operations from each path, the config should look like this:
{ a: { x: 4, y: 0 } }
Order of operations should be:
- Patch B, operation
a.y-> Start with Patch B because it has the lowest priority (should be overridden by higher priority patches) - Patch A, operation
a-> Starts with the least specific operation within Patch A (so it can be overridden by more specific ones) - Patch A, operation
a.x-> It's most specific operation within Patch A
Remarks
Sort MergePatchOperation by descending Unity.Properties.PropertyPath.Length. This allows more specific operations to override less specific ones.
Constructors
MergePatchOperation(string, PropertyPath, object)
Creates a patch operation to merge given value into the config.
public MergePatchOperation(string targetConfigId, PropertyPath propertyPath, object newValue)
Parameters
targetConfigIdstringThe ID of the config to update.
propertyPathPropertyPathThe path to the property to update.
newValueobjectThe new value to set.
Properties
MergeSettings
Settings for JSON merge logic.
public JsonMergeSettings MergeSettings { get; set; }
Property Value
- JsonMergeSettings
PropertyPath
Path to the config property that's being modified. Use empty property path to refer to the whole config.
public PropertyPath PropertyPath { get; }
Property Value
- PropertyPath
TargetConfigId
Target config Id.
public string TargetConfigId { get; }
Property Value
Methods
ApplyTo(JObject)
Apply the operation to the given config.
public bool ApplyTo(JObject config)
Parameters
configJObjectThe config to apply the operation to.
Returns
- bool
True if the operation was successfully applied and resulted in a state change, false otherwise.