<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Power4: Custom property templates and custom event templates</title><link>http://blogs.msdn.com/b/lucian/archive/2010/02/02/power4-custom-property-templates-and-custom-event-templates.aspx</link><description>[This post is part of a series, " wish-list for future versions of VB "] 
 
 IDEA: Custom property templates. We should have an easy way for users to write boiler-plate code in their properties. This would include things like INotifyPropertyChanged</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Power4: Custom property templates and custom event templates</title><link>http://blogs.msdn.com/b/lucian/archive/2010/02/02/power4-custom-property-templates-and-custom-event-templates.aspx#10277431</link><pubDate>Sun, 04 Mar 2012 23:25:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10277431</guid><dc:creator>Shimmy Weitzhandler</dc:creator><description>&lt;p&gt;Interesting.&lt;/p&gt;
&lt;p&gt;Anyway How will you force a getter and a setter? doesn&amp;#39;t it have to fulfill a contract by implementing an interface etc.?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10277431" width="1" height="1"&gt;</description></item><item><title>re: Power4: Custom property templates and custom event templates</title><link>http://blogs.msdn.com/b/lucian/archive/2010/02/02/power4-custom-property-templates-and-custom-event-templates.aspx#9971583</link><pubDate>Tue, 02 Mar 2010 16:37:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9971583</guid><dc:creator>Simon Geering</dc:creator><description>&lt;p&gt;Um interesting. Might be worth talking to Rocky Lhotka as this looks similar to what you do in CSLA business objects with that frameworks Property Manager.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9971583" width="1" height="1"&gt;</description></item><item><title>re: Power4: Custom property templates and custom event templates</title><link>http://blogs.msdn.com/b/lucian/archive/2010/02/02/power4-custom-property-templates-and-custom-event-templates.aspx#9963210</link><pubDate>Sun, 14 Feb 2010 04:27:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9963210</guid><dc:creator>Kevin Ryall</dc:creator><description>&lt;p&gt;We use code gen for dependency property implementation at the moment, but something like this could potentially be a much simpler alternative. Personally, I prefer code syntax solutions to IDE features (I read a lot of code outside the VS IDE), but I’m not sure of the best syntax for this...&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9963210" width="1" height="1"&gt;</description></item><item><title>re: Power4: Custom property templates and custom event templates</title><link>http://blogs.msdn.com/b/lucian/archive/2010/02/02/power4-custom-property-templates-and-custom-event-templates.aspx#9958996</link><pubDate>Fri, 05 Feb 2010 20:40:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9958996</guid><dc:creator>Đonny</dc:creator><description>&lt;p&gt;What about slightly different approach: Specify property template as XML (like snippet) in XML file. (If you really want to make it reusable and have it &amp;quot;compiled&amp;quot; in assembly, it can be placed there as resource. Otherwise just have such XML file as part of project) The template can contain &amp;nbsp;everything what snippet can contain - Property, Backing field, OnXxxChanged event, WPF stuff, attributes, XML doc comments etc. Compiler takes the template in compile time, does some text-based replacements there and compiles result of it (more like C++ macro).&lt;/p&gt;
&lt;p&gt;It's up to template-creator if the template will be created such way it generates 50 lines for each property or if it calls some common validation/storage etc. methods.&lt;/p&gt;
&lt;p&gt;Disadvantage might be that template is not language-independent. Advantage is that it is very flexible.&lt;/p&gt;
&lt;p&gt;==== Templates.xml =====&lt;/p&gt;
&lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;templates xmlns=&amp;quot;&lt;a rel="nofollow" target="_new" href="http://visual-basic.net/templates&amp;quot;&amp;gt;"&gt;http://visual-basic.net/templates&amp;quot;&amp;gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;template name=&amp;quot;NotNullProperty&amp;quot;&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;var name=&amp;quot;$Name$&amp;quot; init=&amp;quot;Name&amp;quot;/&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;var name=&amp;quot;$Type$&amp;quot; init=&amp;quot;Type&amp;quot;/&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;var name=&amp;quot;$Field$&amp;quot; init='&amp;quot;_&amp;quot; + Name.ToLower'/&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;var name=&amp;quot;$Doc$&amp;quot; init=&amp;quot;XmlComment&amp;quot;/&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;var name=&amp;quot;$Attrs$&amp;quot; init=&amp;quot;Attributes&amp;quot;/&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;code&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;![CDATA[&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/// &amp;lt;summary&amp;gt;Contains value of the &amp;lt;see cref=&amp;quot;$Name$&amp;quot;/&amp;gt; property&amp;lt;/summary&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Private $Field$ As $Type$&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$Doc$&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;exception cref=&amp;quot;ArgumentNullException&amp;quot;&amp;gt;Property is being set to &amp;lt;see langword=&amp;quot;null&amp;quot;/&amp;gt;&amp;lt;/exception&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$Attrs$&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Public Property $Name$ As $Type$&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;DebuggerStepThrough&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Get&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Return $Field$&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End Get&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;DebuggerStepThrough&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Set(ByVal value As $Type$)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If value Is Nothing Then Throw New ArgumentNullException(&amp;quot;$Name$ cannot be null&amp;quot;,&amp;quot;value&amp;quot;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$Field$ = value&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End Set&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End Property &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;]]&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;code&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/template&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;/templates&amp;gt;&lt;/p&gt;
&lt;p&gt;=== Class.vb &amp;nbsp;==============&lt;/p&gt;
&lt;p&gt;Class [Class]&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;/// &amp;lt;summary&amp;gt;Gets or sets value&amp;lt;/summary&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Property Value As String From NotNullProperty&lt;/p&gt;
&lt;p&gt;End Class&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9958996" width="1" height="1"&gt;</description></item><item><title>re: Power4: Custom property templates and custom event templates</title><link>http://blogs.msdn.com/b/lucian/archive/2010/02/02/power4-custom-property-templates-and-custom-event-templates.aspx#9957581</link><pubDate>Wed, 03 Feb 2010 15:10:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9957581</guid><dc:creator>Heinzi</dc:creator><description>&lt;p&gt;I'd like to add another usage scenario:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Property Width As Double From New DependencyPropertyClrWrapper(WidthProperty)&lt;/p&gt;
&lt;p&gt;Writing Depenceny Properies in VB is a pain, and this would reduce the current, annoying 8-line&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Public Property Width() As Double&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Get&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Return DirectCast(GetValue(WidthProperty), Double)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End Get&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Set(ByVal value As Double)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SetValue(WidthProperty, value)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End Set&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;End Property&lt;/p&gt;
&lt;p&gt;to a simple one-liner.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9957581" width="1" height="1"&gt;</description></item></channel></rss>