forked from Fody/PropertyChanged
-
Notifications
You must be signed in to change notification settings - Fork 0
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 readsPropertyB
(this.FirstName) -
PropertyA
getter readsPropertyB
's mapped field (this.lastName)