<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Recursive property interceptors</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Recursive property interceptors</description>
  <pubDate>Wed, 13 May 2026 01:56:05 -700</pubDate>
  <lastBuildDate>Tue, 14 Aug 2012 15:12:39 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=3570</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Recursive property interceptors :   Hi Stephen,I&amp;#039;ve checked...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3570&amp;PID=14184#14184</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 3570<br /><strong>Posted:</strong> 14-Aug-2012 at 3:12pm<br /><br />Hi Stephen,<div>&nbsp;</div><div>I've checked with our senior enginner and confirmed that Property interceptors are non-recursive by design.</div><div>&nbsp;</div><div>Imagine if the "top dog" suddenly reports to the someone in the "lower ranks" of the company. (while this is not practical, it's still possible)</div><div>You could get into an infinite loop. </div><div>&nbsp;</div><div>If you want to get the whole "chain of command" from employee A, you could still try something like:</div><div>&nbsp;</div><div><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">&nbsp; public</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> </font></font><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">void</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> GetChainOfCommand(</font></font><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas">Employee</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> emp) {</font></font></div><div><font size="2" face="C&#111;nsolas">&nbsp; &nbsp; </font><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">if</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> (!emp.Employee2.EntityAspect.IsNullEntity) {</font></font></div><div><font size="2" face="C&#111;nsolas">&nbsp; &nbsp;&nbsp;&nbsp; G</font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">etChainOfCommand(emp.Employee2);</font></font></div><div><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">&nbsp;&nbsp; &nbsp;}</font></font></div><div><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">&nbsp; }</font></font></div><div>&nbsp;</div><div>and there assign your custom properties. However, you could&nbsp;still come accross the issue mentioned previously.</div><div>&nbsp;</div><div>Silvio.</div><div>&nbsp;</div><div>&nbsp;</div>]]>
   </description>
   <pubDate>Tue, 14 Aug 2012 15:12:39 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3570&amp;PID=14184#14184</guid>
  </item> 
  <item>
   <title>Recursive property interceptors : It seems like Property Interceptors...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3570&amp;PID=14146#14146</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=613" rel="nofollow">stephenmcd1</a><br /><strong>Subject:</strong> 3570<br /><strong>Posted:</strong> 07-Aug-2012 at 10:18am<br /><br />It seems like Property Interceptors can't call themselves (re-entrancy). &nbsp;On the surface, that seems find but we are running into a case where the Property Interceptor for a property needs to call the same property on a related entity - and in that case, the second interceptor doesn't fire.<div><br></div><div>I'm not sure whether this is a feature or a bug or just us doing something wrong. &nbsp;Since it's a bit confusing to explain, here is some sample code the explains the problem we are having. &nbsp;This is an extra property we added to the partial class. &nbsp;The interceptor on our property looks at that property on a parent entity:<table width="99%"><tr><td><pre class="BBcode">&nbsp; &nbsp; public partial class Employee</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; //Some random property that we have interceptors on</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public string FriendlyText</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get { return PropertyMetadata.FriendlyText.GetValue(this); }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set { PropertyMetadata.FriendlyText.SetValue(this, value); }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &#091;AfterGet("FriendlyText")&#093;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; //Our interceptor that we want to be "recursive"</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public void AfterGetText(PropertyInterceptorArgs&lt;Employee, string&gt; args)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //This is a bit of a contrived example but it illustrates the core problem.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //This property depends on its parent so we re-derive the value each time. &nbsp;And since it</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp;depends on the parent, it is recursive</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //If we don't report to anybody, we are the top dog</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (ReportTo == null || ReportTo.EntityAspect.IsNullEntity)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; args.Value = "Top Dog";</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Otherwise we report to somebody else. &nbsp;Get their 'FriendlyText'</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; args.Value = "Reports to " + ReportTo.FriendlyText;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; public partial class PropertyMetadata</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public static readonly DataEntityProperty&lt;Employee, string&gt; FriendlyText =</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new DataEntityProperty&lt;Employee, string&gt;("FriendlyText", true, false, ConcurrencyStrategy.None, false, null, false);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; }</pre></td></tr></table></div><div><br></div><div>Here is some text code that fails:<table width="99%"><tr><td><pre class="BBcode">&nbsp; &nbsp; private void TestFriendlyText()</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; //Make the boss that doesn't report to anybody</div><div>&nbsp; &nbsp; &nbsp; &nbsp; var boss = new Employee();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; //It should be the top dog</div><div>&nbsp; &nbsp; &nbsp; &nbsp; DebugFns.Assert(boss.FriendlyText == "Top Dog");</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; //Make another person that reports to the boss</div><div>&nbsp; &nbsp; &nbsp; &nbsp; var otherPerson = new Employee();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; otherPerson.ReportTo = boss;</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; //Sanity check: The other person's report to should be Top Dog</div><div>&nbsp; &nbsp; &nbsp; &nbsp; DebugFns.Assert(otherPerson.ReportTo.FriendlyText == "Top Dog");</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; //And finally check our Friendly Text....but this line will fail because it actually equals</div><div>&nbsp; &nbsp; &nbsp; &nbsp; // &nbsp;"Reports to " - the FriendlyText of the ReportsTo return null. &nbsp;:-(</div><div>&nbsp; &nbsp; &nbsp; &nbsp; DebugFns.Assert(otherPerson.FriendlyText == "Reports to Top Dog");</div><div>&nbsp; &nbsp; }</pre></td></tr></table></div><div><br></div>]]>
   </description>
   <pubDate>Tue, 07 Aug 2012 10:18:28 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3570&amp;PID=14146#14146</guid>
  </item> 
 </channel>
</rss>