public partial class Employee {
//Some random property that we have interceptors on
public string FriendlyText
{
get { return PropertyMetadata.FriendlyText.GetValue(this); }
set { PropertyMetadata.FriendlyText.SetValue(this, value); }
}
[AfterGet("FriendlyText")]
//Our interceptor that we want to be "recursive"
public void AfterGetText(PropertyInterceptorArgs<Employee, string> args)
{
//This is a bit of a contrived example but it illustrates the core problem.
//This property depends on its parent so we re-derive the value each time. And since it
// depends on the parent, it is recursive
//If we don't report to anybody, we are the top dog
if (ReportTo == null || ReportTo.EntityAspect.IsNullEntity)
{
args.Value = "Top Dog";
}
else
{
//Otherwise we report to somebody else. Get their 'FriendlyText'
args.Value = "Reports to " + ReportTo.FriendlyText;
}
}
public partial class PropertyMetadata
{
public static readonly DataEntityProperty<Employee, string> FriendlyText =
new DataEntityProperty<Employee, string>("FriendlyText", true, false, ConcurrencyStrategy.None, false, null, false);
}
}