Skip to content

Auto dependencies between properties

Alexander Bondarev edited this page Jan 19, 2022 · 2 revisions

In most case the weaver can automatically find dependencies between properties as described in Property Dependencies article without explicit usage of attributes like AlsoNotifyFor or DependsOn.

I.e.:

[AddINotifyPropertyChangedInterface]
public class MyClass 
{
   private string lastName;

   public string FirstName { get; set; }
   public string LastName  { get => this.lastName; set => this.lastName = value; }
   public string FullName => $"{this.FirstName} {this.lastName}";
}

will emit PropertyChanged event for FullName when either FirstName or LastName changes.

PropertyA depends on PropertyB when:

  • PropertyA getter reads PropertyB (this.FirstName)
  • PropertyA getter reads PropertyB's mapped field (this.lastName)