<?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 : Custom Verifier Attribute?</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Custom Verifier Attribute?</description>
  <pubDate>Mon, 13 Apr 2026 12:29:25 -700</pubDate>
  <lastBuildDate>Thu, 09 Jun 2011 08:14:33 -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=2747</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>Custom Verifier Attribute? : Hi bap1;To create your own custom...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2747&amp;PID=10918#10918</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 2747<br /><strong>Posted:</strong> 09-Jun-2011 at 8:14am<br /><br /><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><div>Hi bap1;</div><div><br></div><div>To create your own custom attribute, you can inherit from one of our pre-defined verifier attribute classes. Below is an example of inheriting from a PropertyValueVerifierAttribute class.</div><div><b><br></b></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><b>//The NullEntityVerifier</b></div><div><b><br></b></div><div><div>&nbsp;&nbsp; &nbsp;public class NullEntityVerifier : PropertyValueVerifier {</div><div>&nbsp;&nbsp; &nbsp; &nbsp;public NullEntityVerifier(Type entityType, String propertyName,</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;String displayName = null, bool? shouldTreatEmptyStringAsNull = null)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;: base(new PropertyValueVerifierArgs(entityType, propertyName, false,</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;displayName, shouldTreatEmptyStringAsNull)) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;public NullEntityVerifier(PropertyValueVerifierArgs args) : base(args) { }</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;protected override VerifierResult VerifyValue(object itemToVerify, object valueToVerify,&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;TriggerContext triggerContext, VerifierContext verifierContext) {</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var entity = (Entity)valueToVerify;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var result = !entity.EntityAspect.IsNullEntity;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return new VerifierResult(result);</div><div>&nbsp;&nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;}</div></div><div><br></div><div><b>//The NullEntityVerifierAttribute</b></div><div><b><br></b></div><div><div>&nbsp;&nbsp; &nbsp;&#091;AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = false)&#093;</div><div>&nbsp;&nbsp; &nbsp;public class NullEntityVerifierAttribute : PropertyValueVerifierAttribute {</div><div>&nbsp;&nbsp; &nbsp; &nbsp;protected override Verifier BuildVerifierCore(Type pType, String propertyName) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return new NullEntityVerifier(</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;new PropertyValueVerifierArgs(pType, propertyName, false, DisplayName,&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GetShouldTreatEmptyStringAsNull())</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;);</div><div>&nbsp;&nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;}</div></div><div><br></div><div><b>//The buddy class</b></div><div><b><br></b></div><div><div>&nbsp;&nbsp; &nbsp;public class EmployeeMetadata {</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;&#091;NullEntityVerifier&#093;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;public static Employee Manager;</div><div>&nbsp;&nbsp; &nbsp;}</div></div><div><br></div><div><b>//The generated code</b></div><div><b><br></b></div><div><div>&nbsp;&nbsp; &nbsp;#region Manager property</div><div><br></div><div>&nbsp;&nbsp; &nbsp;/// &lt;summary&gt;Gets or sets the Manager. &lt;/summary&gt;</div><div>&nbsp;&nbsp; &nbsp;<b>&#091;DomainModel.Employee.NullEntityVerifier&#093;</b></div><div>&nbsp;&nbsp; &nbsp;&#091;Bindable(false)&#093;</div><div>&nbsp;&nbsp; &nbsp;&#091;Display(Name="Manager", AutoGenerateField=false)&#093;</div><div>&nbsp;&nbsp; &nbsp;&#091;DataMember&#093;</div><div>&nbsp;&nbsp; &nbsp;&#091;IbEm.RelationProperty("FK_Employee_Employee", IbEm.QueryDirection.ToRole2)&#093;</div><div>&nbsp;&nbsp; &nbsp;public Employee Manager {</div><div>&nbsp;&nbsp; &nbsp; &nbsp;get { return PropertyMetadata.Manager.GetValue(this); }</div><div>&nbsp;&nbsp; &nbsp; &nbsp;set { PropertyMetadata.Manager.SetValue(this, value); }</div><div>&nbsp;&nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;#endregion Manager property</div></div><div></pre></td></tr></table></div></span>]]>
   </description>
   <pubDate>Thu, 09 Jun 2011 08:14:33 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2747&amp;PID=10918#10918</guid>
  </item> 
  <item>
   <title>Custom Verifier Attribute? :   I found out how to add triggers...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2747&amp;PID=10911#10911</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1091" rel="nofollow">bap1</a><br /><strong>Subject:</strong> 2747<br /><strong>Posted:</strong> 07-Jun-2011 at 6:31pm<br /><br /><p>I found out how to add triggers on specific properties below.&nbsp; Is this the only way how to add a custom verifier?&nbsp; Can I not add a VerifyAttribute on the property of my buddy class?</p><div></div><div></div><p>public static Verifier DirectoryItem_NameVerifier()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string Description = "FirstName and LastName is required for individuals.";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DelegateVerifier&lt;DirectoryItem&gt; v = new DelegateVerifier&lt;DirectoryItem&gt;(Description, DirectoryNameCondition);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>&nbsp;&nbsp; v.AddTriggers(DirectoryItem.PropertyMetadata.FirstName.Name, DirectoryItem.PropertyMetadata.LastName.Name);</strong></p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v.VerifierOptions.ExecutionModes = VerifierExecutionModes.InstanceAndOnAfterSetTriggers;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return v;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>]]>
   </description>
   <pubDate>Tue, 07 Jun 2011 18:31:55 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2747&amp;PID=10911#10911</guid>
  </item> 
  <item>
   <title>Custom Verifier Attribute? :   I&amp;#039;ve created a custom...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2747&amp;PID=10908#10908</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1091" rel="nofollow">bap1</a><br /><strong>Subject:</strong> 2747<br /><strong>Posted:</strong> 07-Jun-2011 at 1:39pm<br /><br />I've created a custom verifer.&nbsp; I'm now trying to apply it to the FirstName property of the Devforce entity using a buddy class but it doesn't like the attribute.&nbsp; Can someone help me here?<div></div><div></div><p>&#091;MetadataType(typeof(DirectoryItemMetaData))&#093;<br>&nbsp;&nbsp;&nbsp; public partial class DirectoryItem<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public class DirectoryItemMetaData<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> &#091;DirectoryItem_NameVerifier()&#093;<br></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static string FirstName;</p><p><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static Verifier DirectoryItem_NameVerifier()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string Description = "FirstName and LastName is required for individuals.";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DelegateVerifier&lt;DirectoryItem&gt; v = new DelegateVerifier&lt;DirectoryItem&gt;(Description, DirectoryNameCondition);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return v;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private static VerifierResult DirectoryNameCondition(DirectoryItem dirItem, TriggerContext triggerContext, VerifierContext verifierContext)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (triggerContext != null &amp;&amp; triggerContext.Timing == TriggerTiming.BeforeSet)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new VerifierException("DirectoryNameValidation is not implemented for Preset.");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!dirItem.IsCompany)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new VerifierResult(!string.IsNullOrEmpty(dirItem.FirstName) &amp;&amp; !string.IsNullOrEmpty(dirItem.LastName));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new VerifierResult(true);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }</p>]]>
   </description>
   <pubDate>Tue, 07 Jun 2011 13:39:02 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2747&amp;PID=10908#10908</guid>
  </item> 
 </channel>
</rss>