Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

"Data binding" for rules #945

Open
rockfordlhotka opened this issue May 5, 2020 · 3 comments
Open

"Data binding" for rules #945

rockfordlhotka opened this issue May 5, 2020 · 3 comments

Comments

@rockfordlhotka
Copy link
Member

I had an idea. Might be good, might be bad, I thought I'd float it out here and see what people think.

The idea is that writing a rule today usually means creating a constructor and adding items to the input properties collection. Which is ok, but not declarative. Also, there's not a good way to reference values from other parts of the object graph - ancestors, siblings, or children of the target object.

I don't have this clearly in my head - but it occurred to me that XAML data binding has mechanisms for binding to ancestors at least. Maybe there's some way to make life better?

  public class MyRule : BusinessRule
  {
    [BindTarget(OrderItem.NameProperty)]
    public string Name { get; set; }
    [BindAncestor(Order.TaxCodeProperty)]
    public string TaxCode { get; set; }
  }

This is pretty vague - what do you think though?

@Chicagoan2016
Copy link

@rockfordlhotka , this would work for 'tightly coupled' business rules (am I a right?), for non-coupled business rules we don't have to use this.

@rockfordlhotka
Copy link
Member Author

Right - I haven't figured out a loosely coupled scheme for data binding. Though maybe something when adding the rule?

  BusinessRules.AddRule<MyRule>(OrderItem.NameProperty, Order.TaxCodeProperty);

I don't actually know how that would be implemented 😄 I'm just playing with ideas here.

@Chicagoan2016
Copy link

I like this approach, it would open all kinds of doors to implement business rules that could access any property in the object graph, exciting times to be a software develoepr :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants