Hi,
We've solved it as shown below. Is that really the way to solve this? I would hate it to have to write that much code for each set of the same property in other Items. We noticed that when we set another property (i.e. not the property that is changing now) then the value is set correctly and it's interceptor is fired too.
Regards,
Paul Sinnema.
Diartis AG
[AfterSet(EntityPropertyNames.IsPostal)]
public void AfterSetIsPostal(PropertyInterceptorArgs<Address, Boolean> args)
{
ResetIsPostal(args);
}
private void ResetIsPostal(PropertyInterceptorArgs<Address, Boolean> args)
{
if (args.Value)
{
foreach (var item in this.Contact.AddressList.Where(address => !address.Equals(this)))
{
if (item.IsPostal)
{
item.IsPostal = false;
FireIsPostalSetters(item, false);
}
}
}
}
private void FireIsPostalSetters(Address address, bool value)
{
var actions = Address.IsPostalEntityProperty.SetterInterceptor.GetActions();
var args = new DataEntityPropertySetInterceptorArgs<Address, Boolean>(Address.IsPostalEntityProperty, address, null);
args.Value = value;
foreach (var item in actions)
{
item.Action(args);
}
}