<?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 : Verification on non-entity properties</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : Verification on non-entity properties</description>
  <pubDate>Thu, 21 May 2026 18:19:40 -700</pubDate>
  <lastBuildDate>Wed, 24 Mar 2010 16:06:53 -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=1683</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>Verification on non-entity properties : Hi Mike, I screwed up and sincerely...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1683&amp;PID=6403#6403</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=477" rel="nofollow">ting</a><br /><strong>Subject:</strong> 1683<br /><strong>Posted:</strong> 24-Mar-2010 at 4:06pm<br /><br /><P>Hi Mike,</P><DIV>I screwed up and sincerely apologize.&nbsp; The code I posted only works if you add a custom property to a DevForce Entity (like ShoeSize to an Employee).&nbsp; It won't work for non-Entity objects, so for that you will need to trigger the verification engine explicitly.</DIV><DIV>&nbsp;</DIV><DIV>I will try and clean up this thread so nobody else gets confused.&nbsp; Once again, sorry for the bad info!</DIV><DIV>&nbsp;</DIV><DIV><strong><EM>Update: This thread&nbsp;now contains correct information</EM></strong></DIV><DIV>&nbsp;</DIV><span style="font-size:10px"><br /><br />Edited by ting - 24-Mar-2010 at 5:36pm</span>]]>
   </description>
   <pubDate>Wed, 24 Mar 2010 16:06:53 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1683&amp;PID=6403#6403</guid>
  </item> 
  <item>
   <title>Verification on non-entity properties : I posted incorrect information...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1683&amp;PID=6373#6373</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=477" rel="nofollow">ting</a><br /><strong>Subject:</strong> 1683<br /><strong>Posted:</strong> 16-Mar-2010 at 7:00pm<br /><br /><DIV><EM><strong>I posted incorrect information earlier.&nbsp; This post has now been corrected and the thread has been cleaned up to avoid confusion.</strong></EM></DIV><DIV>&nbsp;</DIV><DIV>1)&nbsp; Verification will not automatically fire on a POCO object because the verification engine has no way to know when a property has been set in a generic object.&nbsp; Thus, you will need to call it explicitly when you want it triggered (as you've done, although obviously the code could be refactored into a method).</DIV><DIV>&nbsp;</DIV><DIV>However, if you want verification for a custom property (e.g. a non-database property) on a DevForce Entity, you <strong>can</strong> have it automcatically triggered by adding hooks&nbsp;to support DevForce's property interceptors. </DIV><DIV>&nbsp;</DIV><DIV>To support DevForce's property interceptors (which are useful for many things besides verification), you should define your properties like below.&nbsp; This will enable the VerifierEngine to be notified when the property changes.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp;&nbsp; &#091;Attributes removed for clarity&#093;</DIV><DIV>&nbsp;&nbsp;&nbsp; public String ShoeSize {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return ShoeSizeEntityProperty.GetValue(this); }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { ShoeSizeEntityProperty.SetValue(this, value); }<BR>&nbsp;&nbsp;&nbsp; }</DIV><DIV>&nbsp;</DIV><DIV>Then you will need to define&nbsp;a static variable for each property (in this case ShoeSizeEntityProperty) that returns a DataEntityProperty that describes the property.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp; &nbsp; // Note the final false indicating that this is not a datastore-backed property!</DIV><DIV>&nbsp;&nbsp;&nbsp; public static readonly DataEntityProperty&lt;Employee, String&gt; ShoeSizeEntityProperty = </DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new DataEntityProperty&lt;Employee, String&gt;("ShoeSize", false, false, ConcurrencyStrategy.None, false, </DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VerificationSetterOptions.Both, false);</DIV><DIV><BR>&nbsp;</DIV><DIV>You can see more examples of this in our generated code.&nbsp; Note that the final parameter&nbsp;will differ from the generated code as it indicates that the property is not backed by the database.</DIV><DIV>&nbsp;</DIV><DIV>After you invest the time to add the property interceptor hooks to your class, you'll be able to use the VerifierEngine and Property Interceptors on your custom properties the same way they work on the DevForce generated properties.</DIV><DIV>&nbsp;</DIV><DIV>2)&nbsp; On the designer screen for the resource, there is an 'Access Modifier'&nbsp;drop down which you can change from 'internal' to 'public'.&nbsp; If that is not sufficient, you may need to go into the designer.cs file for the resource and change some of the properties to public as well.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><span style="font-size:10px"><br /><br />Edited by ting - 24-Mar-2010 at 5:34pm</span>]]>
   </description>
   <pubDate>Tue, 16 Mar 2010 19:00:55 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1683&amp;PID=6373#6373</guid>
  </item> 
  <item>
   <title>Verification on non-entity properties :     Is it possible to use...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1683&amp;PID=6349#6349</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=704" rel="nofollow">mikewishart</a><br /><strong>Subject:</strong> 1683<br /><strong>Posted:</strong> 11-Mar-2010 at 6:03pm<br /><br />Is it possible to use DevForce verification on non-entity properties?<br><br>for example:<br><br><font color="#000099">public class</font> MyViewModel : INotifyPropertyChanged<br>{<br>&nbsp;&nbsp;&nbsp; <font color="#0000cc">string </font>_valtest;<br>&nbsp;&nbsp;&nbsp; &#091;<font color="#00ccff">StringLengthVerifier</font>(MinValue = 5, MaxValue = 30, IsRequired = <font color="#0000cc">true</font>)&#093;<br>&nbsp;&nbsp;&nbsp; <font color="#0000cc">public string</font> ValTest<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000cc">get </font>{ <font color="#0000cc">return </font>_valtest;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000cc">set </font>{ _valtest = <font color="#0000cc">value</font>; }<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp; <font color="#009900">// OnShow method</font><br>&nbsp;&nbsp; {<br>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <font color="#00ccff">IEntityManagerProvider </font>_entityManagerProvider = <font color="#00ccff">ServiceLocator</font>.Current.GetInstance&lt;<font color="#00ccff">IEntityManagerProvider</font>&gt;();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _entityManagerProvider.EntityManager.VerifierEngine.DiscoverVerifiers(<font color="#0000cc">typeof</font>(<font color="#00ccff">MyViewModel </font>));<br>&nbsp;&nbsp; }<br>}<br><br>Why isn't the trigger firing, or if it is, why no exception?&nbsp; I've verified that the StringLengthVerifier is being placed in the VerifierEngine, so that much is working.<br><br>It works if I throw this code in the setter, but that's not very pretty.&nbsp; <br>&nbsp;&nbsp;&nbsp; <font color="#0000cc">set </font>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#00ccff">IEntityManagerProvider </font>_entityManagerProvider = <font color="#00ccff">ServiceLocator</font>.Current.GetInstance&lt;<font color="#00ccff">IEntityManagerProvider</font>&gt;();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#00ccff">VerifierResultCollection </font>results = _entityManagerProvider.EntityManager.VerifierEngine.Execute(<font color="#0000cc">this</font>,<font color="#990033"> "ValTest"</font>, <font color="#0000cc">value</font>);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000cc">foreach </font>(<font color="#00ccff">VerifierResult </font>aResult <font color="#0000cc">in </font>results)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000cc">if </font>(aResult.IsError)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000cc">throw new </font>Exception(aResult.Description);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _valtest = <font color="#0000cc">value</font>;<br>&nbsp;&nbsp;&nbsp; }<br><br>I've also tried putting the VerifierEngine.Execute() in a &#091;<font color="#0066ff">BeforeSet</font>&#093; adorned method, but the method is never executed.<br><br>Issue #2 - <br>getting an exception:<br><br>"Attempt by method 'IdeaBlade.Validation.VerifierEngine.set_ErrorsResourceManager(System.Resources.ResourceManager)' to access field 'IdeaBlade.Validation.VerifierErrorsResource.resourceMan' failed."<br><br>on the 2nd line of code below:<br><br>DomainModelEntityManager mgr = new DomainModelEntityManager();<br>mgr.VerifierEngine.ErrorsResourceManager = <font color="#0099ff">VerifierErrorsResource</font>.ResourceManager;<br><br>I know "engine" is valid since the previous line sets PropertyNameToDisplayNameTranslator with no problems. VerifierErrorsResource is the resx file found in the DevForce install along with the generated Designer.cs file with the class.<br><br>This works fine in WPF, but fails in Silverlight.&nbsp; (running v5.2.6.0)<br><br>Thanks!<br><br><span style="font-size:10px"><br /><br />Edited by mikewishart - 11-Mar-2010 at 9:57pm</span>]]>
   </description>
   <pubDate>Thu, 11 Mar 2010 18:03:42 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1683&amp;PID=6349#6349</guid>
  </item> 
 </channel>
</rss>