rules-framework
rules-framework copied to clipboard
InMemory providers always returns same instance of rules' object
RuleBuilder
.NewRule<ContentTypes, ConditionTypes>()
.WithName(RmaInvoiceDisclaimerForShippingCostV3)
.WithContent(
ContentTypes.RmaDisclaimerShippingCost,
new DisclaimersValue(
"Freight Cost of {Shipping.AmountInclTax} not to be included in grand total")
)
.WithDateBegin(DateTime.Parse("2019-01-01"))
.Build(),
RuleAddPriorityOption.ByPriorityNumber(1)
Take the above example, if the rule was configured on this away, whenever this rule matches the condition, the instance of the object DisclaimersValue
returned is going to be always the same. It means that if the application changes the content of the object then it will be changed for the entire application.
Perhaps the behavior here should be the rules framework returning a new instance of the object for each time that the rules match the conditions.
Just adding up, this behavior is exclusive to in-memory data source implementation, perhaps the solution can be thought of as part of in-memory implementation (non-binding, just an observation).