<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>AJ's blog &#187; Design Time</title>
	<atom:link href="http://ajdotnet.wordpress.com/category/design-time/feed/" rel="self" type="application/rss+xml" />
	<link>http://ajdotnet.wordpress.com</link>
	<description>Thoughts and informations I think worthwhile to share...</description>
	<lastBuildDate>Sat, 28 Nov 2009 18:43:27 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='ajdotnet.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/e3d62c21bef499236be83d5bda37b578?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>AJ's blog &#187; Design Time</title>
		<link>http://ajdotnet.wordpress.com</link>
	</image>
			<item>
		<title>Silverlight Bits&amp;Pieces &#8211; Part 4: View Model Basics</title>
		<link>http://ajdotnet.wordpress.com/2009/08/27/silverlight-bitspieces-part-4-view-model-basics/</link>
		<comments>http://ajdotnet.wordpress.com/2009/08/27/silverlight-bitspieces-part-4-view-model-basics/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 18:48:40 +0000</pubDate>
		<dc:creator>ajdotnet</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://ajdotnet.wordpress.com/?p=456</guid>
		<description><![CDATA[Note: This is part of a series, you can find the related posts here…

Displaying and manipulating data on the client – the one and only purpose of any LOB application – includes two things if it comes to Silverlight: a) The asynchronous server calls and b) the client architecture. I will be going over them [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=456&subd=ajdotnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><blockquote><p>Note: This is part of a series, you can find the related posts <a href="http://ajdotnet.wordpress.com/category/silverlight/" target="_blank">here</a>…</p>
</blockquote>
<p>Displaying and manipulating data on the client – the one and only purpose of any LOB application – includes two things if it comes to Silverlight: a) The asynchronous server calls and b) the client architecture. I will be going over them in a cursory fashion and come back later to address each one in more depth. This time the client architecture.</p>
<p><strong>View Model basics</strong></p>
<p>The client code is largely guided by the employment of the <a href="http://en.wikipedia.org/wiki/Model_View_ViewModel" target="_blank">Model-View-ViewModel</a> (M-V-VM, or MVVM) approach, which is the predominant architectural approach used with SL and <a href="http://msdn.microsoft.com/en-us/magazine/dd419663.aspx" target="_blank">WPF</a>. The reason probably being that it is a natural counterpart to the WPF and Silverlight data binding features, the two work extremely well together.</p>
<p>Cook book style:</p>
<ul>
<li>For every page (the <em>view</em>) there is a respective class (the <em>view model</em>) that manages the data (the <em>model</em>). </li>
<li>For each control on the view that shall be populated dynamically with data, the view model has a corresponding property providing the model. </li>
<li>For each control state, such as enabled or visible, that shall be controlled by the logic, the view model has a corresponding property, probably boolean. </li>
<li>For each action triggered by the UI the view model has a respective method. </li>
</ul>
<p>The view model is very closely associated with its view, so there is not much reuse here, but then, it largely consists of properties and forwards to service calls. Or so the theory says. (Subsequent posts will gave deal with the shortcomings….)</p>
<blockquote><p>Please note that it is debatable whether the data provided by the view model actually <em>is </em>the model. Another approach would be to expose a view related data model, namely <em>view entities</em>. The view model would have to map them to the data model (<u>the</u> <em>model</em>) the lower layer exposes, probably some service proxy.</p>
<p>Both approaches have pros and cons, however you’ll mostly see the former approach, since it’s well supported by the tools (service proxy generation, etc.). Still, it has some cons…</p>
</blockquote>
<p>Anyway, the only technical demand for view models in SL is due to the intended use for data binding: Classes subject to fully fledged data binding need to support the <em>INotifyPropertyChanged </em>interface for simple properties, while collections have to support <em>INotifyCollectionChanged</em>. The later one comes for free if you use <em>ObservableCollection&lt;T&gt; </em>consequently. (Please note that data binding works with conventional properties, but only to a limited degree.)</p>
<p>For <em>INotifyPropertyChanged </em>a little base class comes in handy:</p>
<p><img src="http://ajdotnet.files.wordpress.com/2009/08/code_npcb.jpg" /> </p>
<p>Note the generic overload. That’s a little trick to avoid typos in the property name argument.</p>
<p>With this class as base a property implementation usually follows this idiom:</p>
<p><img src="http://ajdotnet.files.wordpress.com/2009/08/code_prop.jpg" /> </p>
<p>(Without that trick one would have to pass the property name as string. A source of errors due to typos, and a pitfall during refactoring.)&#160; </p>
<p><em>BookFilter </em>is a data class that, again, follows the same pattern, i.e. it supports <em>INotifyPropertyChanged</em>.</p>
<blockquote><p>Hint: This begs for a code snippet! <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
</blockquote>
<p><strong>The View Model</strong></p>
<p>Any book shelf has a collection of books, so does my application. The book list page should provide a means to filter the book list (two text boxes), a button to trigger the search, and to show the result (a data grid):</p>
<p><img src="http://ajdotnet.files.wordpress.com/2009/08/app_page.jpg" /> </p>
<p>Not especially nice and the grid is a little degenerated for now, but that will change. In XAML:</p>
<p><img src="http://ajdotnet.files.wordpress.com/2009/08/xaml_page.jpg" /> </p>
<p>Thus the first view model implementation may look like this (including some simple test data, the next post will deal with the server call):</p>
<p><img src="http://ajdotnet.files.wordpress.com/2009/08/code_viewmodel.jpg" /> </p>
<p><strong>Databinding</strong></p>
<p>For the actual binding I need to wire that up with the page. The usually presented manual way looks like this:</p>
<p><img src="http://ajdotnet.files.wordpress.com/2009/08/code_page.jpg" /> </p>
<p>The view model class is created in the c’tor, and assigned to the <em>DataContext</em>. A property provides a more convenient access to it. This is already used in the button event handler that triggers the book search.     <br />However, I recommend against this way. Rather I did the data binding in Blend…</p>
<p>Opening the page, selecting the first textbox, finding the <em>Text</em> property in the properties and clicking the text box (or that tiny little dot to the right) brings up the context menu. </p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/08/blend_binding0.png" target="_blank"><img src="http://ajdotnet.files.wordpress.com/2009/08/blend_binding0_tn.png" /></a> </p>
<p>Then I choose data binding, the <em>Data Field </em>tab, and the <em>+CLR Object </em>button:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/08/blend_binding1.png" target="_blank"><img src="http://ajdotnet.files.wordpress.com/2009/08/blend_binding1_tn.png" /></a> </p>
<p>That left finding the view model class and selecting it:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/08/blend_binding2.png" target="_blank"><img src="http://ajdotnet.files.wordpress.com/2009/08/blend_binding2_tn.png" /></a> </p>
<p>This way I <em>could </em>add various “data sources”, yet I only want one for now, and according to M-V-VM, for ever. Afterwards the dialog lets me browse the class structure and select the property to bind against:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/08/blend_binding3.png" target="_blank"><img src="http://ajdotnet.files.wordpress.com/2009/08/blend_binding3_tn.png" /></a> </p>
<p>On second thought, I selected the <em>StackPanel </em>which contains the filter textboxes and bound it against the <em>BookFilter </em>property, in order to narrow the available context. Afterwards the textboxes could be bound via the <em>Explicit Data Context </em>tab:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/08/blend_binding4.png" target="_blank"><img src="http://ajdotnet.files.wordpress.com/2009/08/blend_binding4_tn.png" /></a> </p>
<p>I had to expand the lower area to set the binding to <em>TwoWay</em>. </p>
<p>But I didn’t have to go through the dialog armada for every field. Blend also provides the data tab that lets me browse through the available data sources. Drag’n’drop of field simply works and generally uses the last settings from the dialog, i.e. it includes the <em>TwoWay </em>setting. Also it binds by against the default property, but if I hold the shift key down it lets me choose the property. And some other stuff I leave to you to explore. Really nice.</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/08/blend_binding5.jpg" target="_blank"><img src="http://ajdotnet.files.wordpress.com/2009/08/blend_binding5_tn.jpg" /></a> </p>
<p>Anyway, this is what Blend just created for us in markup speak (just the relevant part):</p>
<p><img src="http://ajdotnet.files.wordpress.com/2009/08/xaml_datasource.jpg" /> </p>
<p>It registered the namespace to locate the view model class, created the view model as resource, set the <em>DataContext </em>of the <em>LayoutRoot </em>element to this resource, and it added the usual binding to the subsequent controls.</p>
<p>Changing the generated prefix to <em>viewModel </em>was all I did. Otherwise I could live very well with that, given that is achieves all I need and it allows me to do my data binding much more efficient and less error prone in Blend. The manual way was opaque to Blend, thus it couldn’t assist me in any way.</p>
<p>The only thing left was removing the manual instantiation from the c’tor and changing the <em>ViewModel </em>property to use the <em>LayoutRoot </em>control. I may have moved the binding to the page instead, but I prefer to work <em>with </em>the tools, not against them.</p>
<p><img src="http://ajdotnet.files.wordpress.com/2009/08/code_vmprop.jpg" /> </p>
<p>After running the application and clicking on the button, it shows the respective test data:</p>
<p><img src="http://ajdotnet.files.wordpress.com/2009/08/app_page2.jpg" /> </p>
<p>The next post will deal with the actual server call. </p>
<p><font color="#008000">That’s all for now folks,      <br /><strong>AJ.NET </strong></font></p>
<p><a href="http://www.dotnetkicks.com/kick/?url=http://ajdotnet.wordpress.com/2009/08/27/silverlight-bitspieces-part-4-view-model-basics/"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2009/08/27/silverlight-bitspieces-part-4-view-model-basics/" border="0" alt="kick it on DotNetKicks.com" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajdotnet.wordpress.com/456/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajdotnet.wordpress.com/456/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajdotnet.wordpress.com/456/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajdotnet.wordpress.com/456/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajdotnet.wordpress.com/456/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajdotnet.wordpress.com/456/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajdotnet.wordpress.com/456/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajdotnet.wordpress.com/456/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajdotnet.wordpress.com/456/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajdotnet.wordpress.com/456/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=456&subd=ajdotnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ajdotnet.wordpress.com/2009/08/27/silverlight-bitspieces-part-4-view-model-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/03b347f75b708670587fdbae73778116?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajdotnet</media:title>
		</media:content>

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/code_npcb.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/code_prop.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/app_page.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/xaml_page.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/code_viewmodel.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/code_page.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/blend_binding0_tn.png" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/blend_binding1_tn.png" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/blend_binding2_tn.png" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/blend_binding3_tn.png" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/blend_binding4_tn.png" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/blend_binding5_tn.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/xaml_datasource.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/code_vmprop.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/app_page2.jpg" medium="image" />

		<media:content url="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2009/08/27/silverlight-bitspieces-part-4-view-model-basics/" medium="image">
			<media:title type="html">kick it on DotNetKicks.com</media:title>
		</media:content>
	</item>
		<item>
		<title>Silverlight Bits&amp;Pieces &#8211; Part 3: First Layout</title>
		<link>http://ajdotnet.wordpress.com/2009/08/21/silverlight-bitspieces-part-3-first-layout/</link>
		<comments>http://ajdotnet.wordpress.com/2009/08/21/silverlight-bitspieces-part-3-first-layout/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 19:48:55 +0000</pubDate>
		<dc:creator>ajdotnet</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://ajdotnet.wordpress.com/?p=422</guid>
		<description><![CDATA[Note: This is part of a series, you can find the related posts here…

One thing is as true with SL as it was with HTML and CSS: Starting with a basic layout of the pages and a “site map” really helps a lot. (Trying to work with a style system that you don’t know doesn&#8217;t.)
The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=422&subd=ajdotnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><blockquote><p>Note: This is part of a series, you can find the related posts <a href="http://ajdotnet.wordpress.com/category/silverlight/" target="_blank">here</a>…</p>
</blockquote>
<p>One thing is as true with SL as it was with HTML and CSS: Starting with a basic layout of the pages and a “site map” really helps a lot. (Trying to work with a style system that you don’t know doesn&#8217;t.)</p>
<p>The application created by the template looks like this:</p>
<p><img src="http://ajdotnet.files.wordpress.com/2009/08/app_template.jpg" /> </p>
<p>It’s a navigation application with head area (including menu) and remaining work area. It uses a <em>Grid </em>control, yet only as kind of canvas, all controls are placed via margins and alignments. I find this, well, curious, there <em>is </em>a canvas control after all. But the layout doesn’t suit me anyway. </p>
<p>So the first step is to get rid of all styles, i.e. I cleaned <em>Assets/Styles.xaml</em>. That included removing all references to these styles, as in this fragment:</p>
<p><img src="http://ajdotnet.files.wordpress.com/2009/08/xaml_hyperlink.jpg" /> </p>
<p>Searching with a little regular expression solves that problem. Now for the intended layout:</p>
<p>I want to have a head area with application title and other information. A left area containing the menu. A bottom line with legal information. And finally the remaining area for our pages. And some space between for some visual separation.</p>
<p>In SL this is done with a <em>Grid</em>. Curiously enough, for this is akin to table layout in HTML. I wonder when the CSS gang will show up and cry wolf <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Most samples show and explain how to write the markup to define rows and columns. But then, most samples are pre-created and reiterated, and I have problems “mind rendering” the markup. With the Silverlight 2 SDK there was at least a kind of preview in VS, but with SL3 that preview does not work (the document outline may help to navigate larger XAML files, though):</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/08/vs_designer.jpg" target="_blank"><img src="http://ajdotnet.files.wordpress.com/2009/08/vs_designer_tn.jpg" /></a> </p>
<p>So I chose a different way and put Blend to its first use…</p>
<p><strong>Grid layout</strong></p>
<p>Defining the desired <em>Grid </em>layout can be done easily in Blend. Placing rows and columns is just a mouse click away: Clicking on the areas to the left or the top adds new rows and columns. Clicking on the symbols changes the type. If you don’t see them, change the layout mode by clicking in the upper left icon.</p>
<p>&#160;<a href="http://ajdotnet.files.wordpress.com/2009/08/blend_grid.jpg" target="_blank"><img src="http://ajdotnet.files.wordpress.com/2009/08/blend_grid_tn.jpg" /></a> </p>
<p>Once the rough layout is done, it can be saved and one can switch back to VS. The resulting markup is very clean, Blend generally does a good job producing clean markup and at the same time leaving your markup as it was. </p>
<p><strong>Placing the contents</strong></p>
<p>Next step was creating controls for the three areas (head, menu, footer) and move the respective content from the page there (copy &amp; paste in VS). The markup now only contains the navigation frame, which is the working area. Drag &amp; drop and some more mouse jostling in Blend positions that control in the correct cell:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/08/blend_position1.png" target="_blank"><img src="http://ajdotnet.files.wordpress.com/2009/08/blend_position1_tn.png" /></a> </p>
<p>And sizing it correctly:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/08/blend_position2.png" target="_blank"><img src="http://ajdotnet.files.wordpress.com/2009/08/blend_position2_tn.png" /></a> </p>
<p>Also – after recompiling the solution – Blend picked up the user controls and offered them as assets if you select <em>Project</em>. Again some mouse jostling later (and with different backgrounds colors for each user control to distinguish them) the result looks like this:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/08/blend_usercontrols.png" target="_blank"><img src="http://ajdotnet.files.wordpress.com/2009/08/blend_usercontrols_tn.png" /></a> </p>
<p>Blend automatically generated a namespace definition as prefix for the controls, using a veeerrrryyyy long prefix name. But that’s easy to solve and to replace with <em>control</em>. The final markup is, again, very clean:</p>
<p><img src="http://ajdotnet.files.wordpress.com/2009/08/xaml_layout.jpg" /> </p>
<p>After some working on the user controls and some styling… <em>alright, it may take some time, but had it ready from some internal application, and besides it was done by a colleague, for if I had done it myself if would probably cause eye cataracts… </em>, the end result looks like this:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/08/app_bookshelf1.png" target="_blank"><img src="http://ajdotnet.files.wordpress.com/2009/08/app_bookshelf_tn1.png" /></a> </p>
<p>This may all seem trivial if you’ve been through this experience once. Bottom line I guess is <em>the way </em>I worked through this (which may or may not work for you). It’s the combination of VS and Blend, working with both tools at the same time. Even if you are a markup guy rather than design time worker in ASP.NET, my recommendation is that you give Blend a chance. It’s far more stable than the ASP.NET designer in VS ever was. I’m not saying you should switch to Blend, just get the best of both, VS and Blend.</p>
<p>The next post will contain some real code, promise <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><font color="#008000">That’s all for now folks,      <br /><strong>AJ.NET</strong></font></p>
<p><a href="http://www.dotnetkicks.com/kick/?url=http://ajdotnet.wordpress.com/2009/08/21/silverlight-bitspieces-part-3-first-layout/"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2009/08/21/silverlight-bitspieces-part-3-first-layout/" border="0" alt="kick it on DotNetKicks.com" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajdotnet.wordpress.com/422/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajdotnet.wordpress.com/422/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajdotnet.wordpress.com/422/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajdotnet.wordpress.com/422/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajdotnet.wordpress.com/422/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajdotnet.wordpress.com/422/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajdotnet.wordpress.com/422/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajdotnet.wordpress.com/422/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajdotnet.wordpress.com/422/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajdotnet.wordpress.com/422/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=422&subd=ajdotnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ajdotnet.wordpress.com/2009/08/21/silverlight-bitspieces-part-3-first-layout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/03b347f75b708670587fdbae73778116?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajdotnet</media:title>
		</media:content>

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/app_template.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/xaml_hyperlink.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/vs_designer_tn.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/blend_grid_tn.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/blend_position1_tn.png" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/blend_position2_tn.png" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/blend_usercontrols_tn.png" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/xaml_layout.jpg" medium="image" />

		<media:content url="http://ajdotnet.files.wordpress.com/2009/08/app_bookshelf_tn1.png" medium="image" />

		<media:content url="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2009/08/21/silverlight-bitspieces-part-3-first-layout/" medium="image">
			<media:title type="html">kick it on DotNetKicks.com</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2010 Architecture Edition</title>
		<link>http://ajdotnet.wordpress.com/2009/03/29/visual-studio-2010-architecture-edition/</link>
		<comments>http://ajdotnet.wordpress.com/2009/03/29/visual-studio-2010-architecture-edition/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 16:04:17 +0000</pubDate>
		<dc:creator>ajdotnet</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[Software Architecture]]></category>
		<category><![CDATA[Software Developers]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://ajdotnet.wordpress.com/?p=258</guid>
		<description><![CDATA[Today I’d like to share another left over from the SDX Talk I mentioned earlier: Basically some screenshots from Visual Studio 2010 Architecture Edition (VSArch from now on). Don’t expect something fancy if you already know VSArch, I just couldn’t find all that much information on the Web beyond the two screenshots on the Microsoft [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=258&subd=ajdotnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Today I’d like to share another left over from the SDX Talk I mentioned <a href="http://ajdotnet.wordpress.com/2009/03/21/going-parallel/" target="_blank">earlier</a>: Basically some screenshots from <strong><em>Visual Studio 2010 Architecture Edition</em></strong> (<em>VSArch </em>from now on). Don’t expect something fancy if you already know VSArch, I just couldn’t find all that much information on the Web beyond the <a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx" target="_blank">two screenshots</a> on the Microsoft site.</p>
<p>The main new things within VSArch include the <em>Architecture Explorer</em>, <em>UML Support</em>, and the <em>Layer Diagram</em>.</p>
<p><strong>Architecture Explorer</strong></p>
<p><em>Note: To make the following more tangible I loaded a sample project I use regularly as test harness and took respective screenshots while I analyzed it. Click the images for a larger view…</em></p>
<p>The Architecture Explorer is about getting a better view into existing code. Whether you join a project that is under way, whether you have lost control over your code, or whether you just need to spice up your documentation. Architecture Explorer helps you by visualizing your solution artifacts and dependencies. Artifacts include the classical code artifacts (classes, interfaces, etc.), as well as whole assemblies, files, and namespaces.</p>
<p>Architecture Explorer lets you select those artifacts, display graphs with dependencies, and even navigate along those dependencies and in and out of detail levels.</p>
<p>The following screenshot shows VSArch. The docked pane on the bottom contains the Architecture Explorer that acts as “navigation and control center”. This is where you select your artifacts and visualizations. It could certainly use some improvement from a usability perspective, but it does the job anyway.</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/03/vsarch_assemblies.jpg" target="image"><img src="http://ajdotnet.files.wordpress.com/2009/03/vsarch_assemblies_small.jpg" alt="vsarch_assemblies.jpg" /></a></p>
<p>The screenshot shows two different visualizations of the assembly dependencies in my solution, a matrix view and a directed graph. Just to stress the fact: This was generated out of the solution, by analyzing the project dependencies.</p>
<p>The next screenshot shows a mixture of various artifacts, including classes, interfaces, even files, across parts of or the whole solution.</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/03/vsarch_artifacts.jpg" target="image"><img src="http://ajdotnet.files.wordpress.com/2009/03/vsarch_artifacts_small.jpg" alt="vsarch_artifacts.jpg" /></a></p>
<p>Depending on what filters you set, this graph could give you a high level overview of certain artifacts and their dependencies. For example you could easily spot hot spots, like the one class your whole system depends upon. Or make sure the dependencies are nicely managed via interfaces and find undue relationships. Even spot unreferenced and therefore dead graphs.</p>
<p>Once you go one level deeper, you may want to cluster the artifacts by some category.</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/03/vsarch_relationship.jpg" target="image"><img src="http://ajdotnet.files.wordpress.com/2009/03/vsarch_relationship_small.jpg" alt="vsarch_relationship.jpg" /></a></p>
<p>The image shows again artifacts and their dependencies, but this time grouped by the project to which they belong. It also shows what kind of relationship a line represents and lets you navigate along that dependency.</p>
<p>The Architecture Explorer should help getting a better understanding of your code. It helps you to detect <a href="http://en.wikipedia.org/wiki/Code_smells" target="_blank">code smells</a> or may guide your refactoring.</p>
<p><strong>UML Support</strong></p>
<p>Yes, UML like in, well <a href="http://en.wikipedia.org/wiki/Unified_Modeling_Language" target="_blank">UML</a>. Not extensively, but it includes activity diagram, component diagram, (logical) class diagram, sequence diagram, and use case diagram. I didn’t spend much time investigating them, just drew some diagrams in order to take the screen shots. Generally I can say that Microsoft can draw boxes and lines (big surprise here) but there is a lingering feeling that those diagram editors may not be finished yet (again, hardly surprising on a CTP).</p>
<p>Creating a new diagram is easy enough. Just create a new project of type “Modeling Project” and add an item:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/03/vsarch_dialog.jpg" target="image"><img src="http://ajdotnet.files.wordpress.com/2009/03/vsarch_dialog_small.jpg" alt="vsarch_dialog.jpg" /></a></p>
<p>Everything starts with a use case, so here is our <strong>use case diagram</strong>:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/03/vsarch_usecase.jpg" target="image"><img src="http://ajdotnet.files.wordpress.com/2009/03/vsarch_usecase_small.jpg" alt="vsarch_usecase.jpg" /></a></p>
<p>One can draw the diagram as he likes. As you can see from the context menu, there is something being worked on. Namely the “Link to Artifacts” entry shows the Architecture Explorer, yet I couldn’t quite figure out what’s behind this. Also note the validate entries which didn’t do very much, but we’ll see them later in the Layer Diagram.</p>
<p>Next on the list is <strong>activity diagram</strong>s:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/03/vsarch_activity.jpg" target="image"><img src="http://ajdotnet.files.wordpress.com/2009/03/vsarch_activity_small.jpg" alt="vsarch_activity.jpg" /></a></p>
<p>Works as expected, no surprises, no hidden gems that I’ve found.</p>
<p>The same is true for the <strong>component diagram</strong>:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/03/vsarch_component.jpg" target="image"><img src="http://ajdotnet.files.wordpress.com/2009/03/vsarch_component_small.jpg" alt="vsarch_component.jpg" /></a></p>
<p>Just a diagram, no surprises.</p>
<p>The <strong>logical class diagram </strong>gets more interesting:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/03/vsarch_logicalclass.jpg" target="image"><img src="http://ajdotnet.files.wordpress.com/2009/03/vsarch_logicalclass_small.jpg" alt="vsarch_logicalclass.jpg" /></a></p>
<p>As you can see, it contains very .NETy stuff like enumerations. It also has these menu entries that hint on more to come in the future &#8212; right now the selected menu entry brings up the error message asking for a stereotype, yet I didn’t even find a way to set those. Also the editor may still need some work, e.g. one cannot drag classes in and out of packages.</p>
<p>As a side note: The relation between this logical class diagram and the already existing class diagram escapes me. At least they are a little redundant.</p>
<p>Next on the list is the <strong>sequence diagram</strong>. Rather than drawing one myself I reverse engineered the existing code:</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/03/vsarch_sequence.jpg" target="image"><img src="http://ajdotnet.files.wordpress.com/2009/03/vsarch_sequence_small.jpg" alt="vsarch_sequence.jpg" /></a></p>
<p>Quite nice and again, used this way it can help you documenting or just plain understanding existing code.</p>
<blockquote><p>Note: If you want to try that yourself, the CTP has a bug: You need to have a modeling project and at least one diagram before the menu entry “Generate Sequence Diagram” appears. And while you will be presented with a dialog asking what call depth to analyze, it usually works only for one level.</p></blockquote>
<p><strong>Layer Diagram.</strong></p>
<p>Now for the most dreadfully looking diagram (though Microsoft has a <a href="http://www.microsoft.com/visualstudio/en-us/content/images/screencap3.png" target="_blank">more colorful one</a> on its site…): Some boring connected blocks, meant to represent the layers of your architecture.</p>
<p><a href="http://ajdotnet.files.wordpress.com/2009/03/vsarch_layer.jpg" target="image"><img src="http://ajdotnet.files.wordpress.com/2009/03/vsarch_layer_small.jpg" alt="vsarch_layer.jpg" /></a></p>
<p>Actually this is one of the most interesting features for any architect and dev lead: <em>It’s a living beast! <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_evil.gif' alt=':evil:' class='wp-smiley' /> </em> </p>
<p>You can add assemblies as well as other artifacts to the bleak boxes. Afterwards you can actually validate whether the dependencies between those artifacts match or violate the dependencies implied by the diagram. In the screenshot you can see that I deliberately misplaced an assembly and consequently got a respective error. Using this feature an architect can ensure that all layer related architectural decisions are honored during development.</p>
<p><strong>To conclude… </strong></p>
<p>The Architecture Explorer is certainly a worthwhile feature and I also like the validation feature of the Layer Diagram. That’s certainly something new and not to be found in other products.</p>
<p>Generating sequence diagrams is nice but it remains to be seen whether this will allow roundtrip engineering. The logical class diagram doesn’t yet meet my expectations and it’s not quite clear to me how it will evolve. The other diagrams? Well, they just work. However in this group is nothing exciting for you if you already have another modeling tool like <a href="http://www.sparxsystems.com/products/ea/index.html" target="_blank">Enterprise Architect</a> (no advertising intended, just happens to be the one I’ve used recently…). And a dedicated tool probably will provide a more complete UML coverage. UML 2.0 has <a href="http://en.wikipedia.org/wiki/Unified_Modeling_Language#Diagrams_overview" target="_blank">13 types of diagrams</a>, including state diagrams, which is in my opinion the biggest gap in VSArch UML support.</p>
<p>Anyway, if that caught your attention and your interested in more details there are two options: One, <a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx" target="_blank">download the CTP</a> and try for yourself. Two, if you want it more condensed and avoid the hassle with a VPC, watch a video with VSArch at work. For that there are two links I can provide:</p>
<ol>
<li>Peter Provost’s talk at the PDC. Go to the <a href="https://sessions.microsoftpdc.com/public/timeline.aspx" target="_blank">timeline on the PDC site</a>, search for TL15 and you should find “TL15 Architecture without Big Design Up Front”, which is about VSArch, despite the title. His talk was the role model for my analysis of VSArch, yet seeing it live could still give better insights.</li>
<li><a href="http://channel9.msdn.com/posts/VisualStudio/Visual-Studio-Team-System-2010-Week-on-Channel-9/" target="_blank">Visual Studio Team System 2010 Week on Channel 9</a> has a bunch of videos, especially the “Architecture Day” ones. “top down” and “bottom up” show VSArch at work.</li>
</ol>
<p>The final question however will be if all those features are compelling enough to actually <em>buy </em>the … <a href="http://www.microsoft.com/visualstudio/en-us/products/teamsystem/default.mspx#compare_products" target="_blank">Visual Studio Team Suite</a> (i.e. the “you get everything” package). Why not the Architecture Edition? Well, if you are a developer as well as an architect, the Architecture Edition lacks too much in the other areas. Given that there is usually quite a monetary gap between dev edition and team suite, that gap might very well be used to buy a 3rd party UML tool instead… .</p>
<p><span style="color:#008000;">That’s all for now folks,<br />
<strong>AJ.NET</strong></span><br />
<a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fajdotnet.wordpress.com%2f2009%2f03%2f29%2fvisual-studio-2010-architecture-edition%2f"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fajdotnet.wordpress.com%2f2009%2f03%2f29%2fvisual-studio-2010-architecture-edition%2f" border="0" alt="kick it on DotNetKicks.com" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajdotnet.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajdotnet.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajdotnet.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajdotnet.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajdotnet.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajdotnet.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajdotnet.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajdotnet.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajdotnet.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajdotnet.wordpress.com/258/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=258&subd=ajdotnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ajdotnet.wordpress.com/2009/03/29/visual-studio-2010-architecture-edition/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/03b347f75b708670587fdbae73778116?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajdotnet</media:title>
		</media:content>

		<media:content url="http://ajdotnet.files.wordpress.com/2009/03/vsarch_assemblies_small.jpg" medium="image">
			<media:title type="html">vsarch_assemblies.jpg</media:title>
		</media:content>

		<media:content url="http://ajdotnet.files.wordpress.com/2009/03/vsarch_artifacts_small.jpg" medium="image">
			<media:title type="html">vsarch_artifacts.jpg</media:title>
		</media:content>

		<media:content url="http://ajdotnet.files.wordpress.com/2009/03/vsarch_relationship_small.jpg" medium="image">
			<media:title type="html">vsarch_relationship.jpg</media:title>
		</media:content>

		<media:content url="http://ajdotnet.files.wordpress.com/2009/03/vsarch_dialog_small.jpg" medium="image">
			<media:title type="html">vsarch_dialog.jpg</media:title>
		</media:content>

		<media:content url="http://ajdotnet.files.wordpress.com/2009/03/vsarch_usecase_small.jpg" medium="image">
			<media:title type="html">vsarch_usecase.jpg</media:title>
		</media:content>

		<media:content url="http://ajdotnet.files.wordpress.com/2009/03/vsarch_activity_small.jpg" medium="image">
			<media:title type="html">vsarch_activity.jpg</media:title>
		</media:content>

		<media:content url="http://ajdotnet.files.wordpress.com/2009/03/vsarch_component_small.jpg" medium="image">
			<media:title type="html">vsarch_component.jpg</media:title>
		</media:content>

		<media:content url="http://ajdotnet.files.wordpress.com/2009/03/vsarch_logicalclass_small.jpg" medium="image">
			<media:title type="html">vsarch_logicalclass.jpg</media:title>
		</media:content>

		<media:content url="http://ajdotnet.files.wordpress.com/2009/03/vsarch_sequence_small.jpg" medium="image">
			<media:title type="html">vsarch_sequence.jpg</media:title>
		</media:content>

		<media:content url="http://ajdotnet.files.wordpress.com/2009/03/vsarch_layer_small.jpg" medium="image">
			<media:title type="html">vsarch_layer.jpg</media:title>
		</media:content>

		<media:content url="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fajdotnet.wordpress.com%2f2009%2f03%2f29%2fvisual-studio-2010-architecture-edition%2f" medium="image">
			<media:title type="html">kick it on DotNetKicks.com</media:title>
		</media:content>
	</item>
		<item>
		<title>partial methods for partial developers</title>
		<link>http://ajdotnet.wordpress.com/2007/09/04/partial-methods-for-partial-developers/</link>
		<comments>http://ajdotnet.wordpress.com/2007/09/04/partial-methods-for-partial-developers/#comments</comments>
		<pubDate>Tue, 04 Sep 2007 18:19:37 +0000</pubDate>
		<dc:creator>ajdotnet</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Software Developers]]></category>

		<guid isPermaLink="false">http://ajdotnet.wordpress.com/2007/09/04/partial-methods-for-partial-developers/</guid>
		<description><![CDATA[The evolution of C# has all but stopped. One addition with .NET 2.0 was partial classes. Probably meant to ease the usage of code generators (keeping generated code separate from hand written code) the common developer is not limited to &#8220;consuming&#8221; it, he may also actively employ it. E.g. it might serve a puprose to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=114&subd=ajdotnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The evolution of C# has all but stopped. One addition with .NET 2.0 was partial classes. Probably meant to ease the usage of code generators (keeping generated code separate from hand written code) the common developer is not limited to &#8220;consuming&#8221; it, he may also actively employ it. E.g. it might serve a puprose to separate production code from debug code. With .NET 3.5 there already was much talk about the language additions around LINQ, such as &#8230; well, just have a look at <a target="_blank" href="http://msdn2.microsoft.com/en-us/netframework/aa904594.aspx">The LINQ Project</a> or <a target="_blank" href="http://weblogs.asp.net/scottgu/archive/tags/LINQ/default.aspx">ScottGu&#8217;s Blog</a>. And of course, these features are <em>meant </em>to be actively employed by the common developer.</p>
<p>Now we have a relatively new addition: Partial methods. (In case you haven&#8217;t hread, see <a target="_blank" href="http://blogs.msdn.com/wesdyer/archive/2007/05/23/in-case-you-haven-t-heard.aspx">In Case You Haven&#8217;t Heard</a>, see <a target="_blank" href="http://blogs.msdn.com/vbteam/archive/2007/03/27/partial-methods.aspx">Partial Methods</a> for the VB.NET camp). With this addition I&#8217;m not so sure it&#8217;s meant for me&#8230; .</p>
<blockquote><p>For the record: A partial method is a method <em>declared </em>in a partial class (hence the name). It may or may not be <em>implemented </em>in the same class (usually in another file). If it is implemented, the compiler will emit usual code. If it is not implemented, the compiler will emit nothing, not even metadata about that method. And will will also wipe out any calls to the method.</p>
<p>Ergo: Partial methods are purely a compiler feature. You need the code of the declaring class and it has to be prepared with declarations to support partial method implementation.</p></blockquote>
<p>The usual (probably the only relevant) use case for partial methods is <strong>light weight event handling</strong> in combination with <strong>code generation</strong>. Say, you parse a database or an XML file and generate data classes. Tens of classes, hundreds of properties, all fairly generic, boilerplate stuff. And also fairly common is the need to interfere with this method for validation or that property setter to update another one. So instead of manipulating the generated code or having hundreds of events and thousands of method calls during runtime (of which in most cases only a tiny fraction will actually do something) partial methods kick in. They are easier to declare and use than events (pay for what you need) and if not used they simply vanish (pay as you go).</p>
<p>Any other relevant use case? None that I am aware of. In other words we have a language feature that is very efficient for a very limited number of use cases.</p>
<p><strong>For whom are partial methods made?</strong></p>
<p>Implementors of code generators are the ones to employ partial methods. Today this means Microsoft and LINQ related stuff, tomorrow Microsoft may decide to use partial methods in other event laden environments, such as ASP.NET and WinForms. In these cases the common developer only consumes partial methods. Let me re-phrase this: The common developer <em>has </em>to consume partial methods. Why? With partial methods the code generator will certainly not generate any other means of extension, such as events or virtual methods. The very purpose of partial methods is to do away with these heavy weight means, right?</p>
<p><u>The pro:</u> If you follow the designer driven, RAD style, code based development style that ASP.NET or WinForms used for quite some time, the designer will eventually handle partial methods transparently. The only difference for the common developer is that he knows the stuff he is doing will be more efficient at runtime.</p>
<p><u>The con:</u> If you like metadata driven applications (and already struggled with ASP.NET databinding because there is no way to attach meta data)&#8230; well, prepare for some further loss of information. If you need some event for any property setter (for tracing or tracking), if you need any kind of dynamic behaviour (e.g. to attach some kind of generic rules engine),  &#8230; let&#8217;s just hope the developer of the code generator anticipated that use case (or prepare for some work). You have a clean layer separation and the entities should know nothing about the UI? Well, put your code riht into the data class will spoil that. But hey, you might use partial methods to implement real events. Manually.</p>
<p>So you and I, the common developer that is, will not gain very much from this use case. But we will become more dependend on the ability, the mercy, and the foresight of the developers of the code generators and designers.</p>
<p>Will we be able to employ partial methods (rather than only consuming them)? Let&#8217;s see&#8230; when did I last write a class that had to support a vast amount of events? (That actually occasionally happens when I lay some infrastructure for the next project or work on framework code.) A class that was at the same time <em>not </em>intended to act as base class? (OK, forget about the infastructure!). But I surely wrote code by hand (because there was no code generator) that looks exactly like a candidate? But then I simply wrote the methods I needed, as I needed them &#8212; no need for a partial declaration.</p>
<p>So, unless I enter the camp of the not-so-common-code-generator-writing-developers (it happens, but only rarely), I can see no relevant use case that allows me to employ partial methods. (I really don&#8217;t count the example of increasing the readability conditional compilation &#8212; as presented in the VB post above &#8212; as relevant for a new language feature.)</p>
<p>Again, for whom are partial methods made? In my opinion they are made for Microsoft. To help them writing code generators that generate more efficient code. Code that conforms with the constant shift from object oriented (inheritance and virtual methods), component oriented (interfaces, events), metadata driven (attributes) development to a more and more exclusively used code generation approach. Highly efficient, but really not meant for me.</p>
<p>Do I have a better solution for the problem partial methods solve? I don&#8217;t. Therefore I can&#8217;t blame Microsoft for putting them in. Do I have concerns about how that will affect my work? I certainly do. Therefore I do hope the developers employing them do it with utmost caution. And with the awareness that not everyone uses their tools in a point-and-click kind of fashion.</p>
<blockquote><p>There already has been some concern about partial methods in the .NET community &#8212; and for other reasons than the ones I mentioned: Language complexity, naming issues, other features higher on the wish list, and so on. I recommend reading the comments of the post above if you want to keep up with that. Whether partial methods are a good idea or not, they are easily the single most controversial language feature in C# so far.</p></blockquote>
<p><font color="#008000">That&#8217;s all for now folks,<br />
<strong>AJ.NET</strong></font><br />
<a href="http://www.dotnetkicks.com/kick/?url=http://ajdotnet.wordpress.com/2007/09/04/partial-methods-for-partial-developers/"><img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2007/09/04/partial-methods-for-partial-developers/" alt="kick it on DotNetKicks.com" /></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajdotnet.wordpress.com/114/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajdotnet.wordpress.com/114/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajdotnet.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajdotnet.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajdotnet.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajdotnet.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajdotnet.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajdotnet.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajdotnet.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajdotnet.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajdotnet.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajdotnet.wordpress.com/114/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=114&subd=ajdotnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ajdotnet.wordpress.com/2007/09/04/partial-methods-for-partial-developers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/03b347f75b708670587fdbae73778116?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajdotnet</media:title>
		</media:content>

		<media:content url="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2007/09/04/partial-methods-for-partial-developers/" medium="image">
			<media:title type="html">kick it on DotNetKicks.com</media:title>
		</media:content>
	</item>
		<item>
		<title>List the List</title>
		<link>http://ajdotnet.wordpress.com/2007/03/24/list-the-list/</link>
		<comments>http://ajdotnet.wordpress.com/2007/03/24/list-the-list/#comments</comments>
		<pubDate>Sat, 24 Mar 2007 15:51:17 +0000</pubDate>
		<dc:creator>ajdotnet</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Design Time]]></category>

		<guid isPermaLink="false">http://ajdotnet.wordpress.com/2007/03/24/list-the-list/</guid>
		<description><![CDATA[This post is again going deep down to the bits (writing on high-level topics takes so much more time&#8230;).
Suppose (again) you were writing some kind of generic serializer or databinding code. Sooner or later you would have to deal with lists. Collections. Arrays. In other words, you would have to deal with a situation like [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=102&subd=ajdotnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This post is again going deep down to the bits (writing on high-level topics takes so much more time&#8230;).</p>
<p>Suppose (again) you were writing some kind of generic serializer or databinding code. Sooner or later you would have to deal with lists. Collections. Arrays. In other words, you would have to deal with a situation like this: </p>
<blockquote><p><font color="#0000ff">public</font> <font color="#0000ff">class</font> MyObject<br />
{<br />
    <font color="#008000"><em>// &#8230;</em></font><br />
}</p>
<p><font color="#0000ff">public</font> <font color="#0000ff">class</font> MyCollection : CollectionBase<br />
{<br />
    <font color="#008000"><em>// &#8230;</em></font><br />
}</p>
<p><font color="#0000ff">public</font> <font color="#0000ff">class</font> Data<br />
{<br />
    <font color="#0000ff">public</font> <strong><font color="#0000ff">MyObject</font>[]</strong> MyObjectArray { <font color="#008000"><em>/* &#8230; *</em></font>/ }<br />
    <font color="#0000ff">public</font> <strong>MyCollection</strong> CollectionOfMyObject { <font color="#008000"><em>/* &#8230; *</em></font>/ }<br />
    <font color="#0000ff">public</font><strong> IList&lt;MyObject&gt;</strong> GenericListOfMyObject { <font color="#008000"><em>/* &#8230; *</em></font>/ }</p>
<p>    <font color="#0000ff">public</font> <strong>ArrayList</strong> ListOfMyObjects { <font color="#008000"><em>/* &#8230; *</em></font>/ }<br />
    <font color="#0000ff">public</font> <font color="#0000ff"><strong>object</strong></font> ThisCouldBeAListOfMyObjects { <font color="#008000"><em>/* &#8230; *</em></font>/ }<br />
}</p></blockquote>
<p>In order to analyze some arbitrary object (say an instance of <em>Data</em>), you would use either <em>type.GetProperties()</em> (more suited for serializers) or <em>TypeDescriptor.GetProperties(type)</em> (the better choice for databinding and design time related stuff). You would then look at each property&#8217;s type, recognize it is a collection type, and somehow deduce the type of the collection elements (to create them dynamically or to read their properties to create list columns during databinding).</p>
<p>Let&#8217;s have a look on what our code could be presented with:</p>
<ol>
<li><strong>Arrays. </strong>They are the most simple collection type, embedded in the language, and are often used by code generation tools. Supporting them is a must.</li>
<li>Collection classes derived from <em><strong>CollectionBase</strong></em>. MSDN <a target="_blank" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionscollectionbaseclasstopic.asp">states</a> that<br />
    <em>&#8220;This base class [CollectionBase] is provided to make it easier for implementers to create a strongly typed custom collection. Implementers should extend this base class instead of creating their own.&#8221;</em><br />
Therefore <em>CollectionBase</em> was the means of choice before we had generics. Please note that this class comes with a pattern that implies type safe methods in the derived class.</li>
<li>Collections implementing <strong><em>ICollection </em>or <em>IList</em></strong>. This is a more generic approach than using <em>CollectionBase</em>. We will have to look closer at this, but if it worked, it would automatically cover the <em>ColectionBase </em>approach.</li>
<li>Generic collections, implementing <strong><em>ICollection&lt;T&gt;</em> or <em>IList&lt;T&gt;</em></strong>. This is propably the way new code will present collections to our code. Please note that a bunch of methods (like <em>Add</em>, <em>Remove</em>, etc.) that are in the non-generic version part of <em>IList </em>have been pushed down to <em>ICollection&lt;T&gt; </em>in the generic version.</li>
<li>The predefined collection classes in the <em>System.Collections</em> namespace, notably <em><strong>ArrayList</strong></em>, will also have been used quite often.</li>
<li>There is a special interface <em><strong>ITypedList</strong></em>, meant to support databinding. This may help (or it may not.)</li>
<li>Finally we may have to deal with collections that may be present in some <strong>untyped property</strong>.</li>
</ol>
<p>Now let&#8217;s see which of these cases we can support to what degree:</p>
<p><em><strong>Arrays: </strong></em>You can check if it&#8217;s an array using <em>Type.IsArray</em> and use Type.GetElementType() to get the type of the elements.<br />
 <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_arrow.gif' alt=':arrow:' class='wp-smiley' />  Supporting arrays is mandatory and no sweat at all. 100% done.</p>
<p><em><strong>CollectionBase, ICollection/IList: </strong></em>Neither <em>CollectionBase </em>nor one of the interfaces (also implemented by <em>CollectionBase</em>) tell you something about the element type. The usage of <em>CollectionBase</em> however implies a pattern that will have the implementor support type safe overloads of the usuall collection methods. What we can do is get hold of one of those members (e.g. the <em>Add </em>method or the indexer) and analyze its type.<br />
 <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_arrow.gif' alt=':arrow:' class='wp-smiley' />  Supporting arbitrary <em>ICollection</em> classes can be done if they adhere to some pattern (implied by but not restricted to <em>CollectionBase</em>). Let&#8217;s call that 90% covered.</p>
<p><em><strong>ICollection&lt;T&gt;/IList&lt;T&gt;: </strong></em>This case is as easy as arrays are. Well, appart from <a href="http://ajdotnet.wordpress.com/2006/08/01/is-getinterface-broken/">figuring out the interface</a>. But let&#8217;s ignore this exotic cases and settle with, say 99% coverage? Once you got hold of the interface it&#8217;s just a matter of calling <em>type.GetGenericArguments()</em>.<br />
 <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_arrow.gif' alt=':arrow:' class='wp-smiley' />  Supporting generic collections is mandatory and no sweat at all. 99% done.</p>
<p><em><strong>ArrayList: </strong></em>Here we will raise the white flag. The type of ArrayList does not tell us anything about the element type and no way to get it working. Can we live with that? <em>ArrayList </em>is &#8220;not the best choice&#8221; as property type, so this restriction might be the encouragement the developer needed to improve his data structures&#8230; (allways point out the positive aspects <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  )<br />
 <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_arrow.gif' alt=':arrow:' class='wp-smiley' />  Supporting ArrayList stays at 0%.</p>
<p><em><strong>ITypedList: </strong></em>ITypedList will give you direct access to the element&#8217;s properties (similar to <em>TypeDescriptor.GetProperties(type)</em>). This may be usefull for databinding and design time features &#8212; in fact I would regard that as a must, since it is part of the databinding infrastructure of .NET.<br />
For serializers might be used to get the properties and guess the component type (&#8220;von hinten durch die Brust ins Auge&#8221; &#8212; german proverb, literally &#8221;from the back through the cest into the eye&#8221;, used for arkward indirect ways to achive something). I would consider that only if I absolutely had to.<br />
 <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_arrow.gif' alt=':arrow:' class='wp-smiley' />  Supporting ITypedList depends on the purpose of our code. For databinding it should be considered (100% coverage), for serializers it may be a fallback chance, though unreliable. No more than 50% coverage.</p>
<p><em><strong>Untyped property: </strong></em>No type, no chance to even know it&#8217;s a collection.<br />
 <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_arrow.gif' alt=':arrow:' class='wp-smiley' />  0%.</p>
<p><strong>Further complications&#8230;</strong></p>
<p>So far we&#8217;ve looked at collection types, not at elements. If the collection type does not tell us enough, we may look at the first element in the collection. Asuming that there is one. If not, a serializer might have no problem, yet a databinding scenario might &#8212; which is the very reason Microsoft came up with <em>ITypedList</em>.</p>
<p>Another aspect has so far been ignored: We &#8230; (OK, <em>I</em>) asumed homogenous collections, i.e. collections of elements of the same type. Collections containing elements of different types (they may have a common base class, or be completely arbitrary) will pose a whole new bunch of problems. This is probably beyond what databinding can support, serializers would have to make sure that each list entry is stored along with type information.</p>
<p><strong>Where are we?</strong></p>
<p>If you take a look at what can be supported and what can&#8217;t, you&#8217;ll notice that it is simply not possible to cover 100% of the theoretically possible cases. Even some feasible cases will only be covered by 80%. However, if you look closer, those 80% may very well be all you&#8217;ll ever need. And if you really stumble over one of the 20% cases (<em>ArrayList</em> might be one of those), don&#8217;t try to guess out of the blue; think of some way to feed additional meta information into your serializer.</p>
<p><font color="#008000">That&#8217;s all for now folks,<br />
<strong>AJ.NET</strong></font><br />
<a href="http://www.dotnetkicks.com/kick/?url=http://ajdotnet.wordpress.com/2007/03/24/list-the-list/"><img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2007/03/24/list-the-list/" alt="kick it on DotNetKicks.com" /></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajdotnet.wordpress.com/102/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajdotnet.wordpress.com/102/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajdotnet.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajdotnet.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajdotnet.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajdotnet.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajdotnet.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajdotnet.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajdotnet.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajdotnet.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajdotnet.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajdotnet.wordpress.com/102/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=102&subd=ajdotnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ajdotnet.wordpress.com/2007/03/24/list-the-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/03b347f75b708670587fdbae73778116?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajdotnet</media:title>
		</media:content>

		<media:content url="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2007/03/24/list-the-list/" medium="image">
			<media:title type="html">kick it on DotNetKicks.com</media:title>
		</media:content>
	</item>
		<item>
		<title>New version of my AddIn&#8230;</title>
		<link>http://ajdotnet.wordpress.com/2007/03/10/new-version-of-my-addin/</link>
		<comments>http://ajdotnet.wordpress.com/2007/03/10/new-version-of-my-addin/#comments</comments>
		<pubDate>Sat, 10 Mar 2007 19:25:45 +0000</pubDate>
		<dc:creator>ajdotnet</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[Software Developers]]></category>

		<guid isPermaLink="false">http://ajdotnet.wordpress.com/2007/03/10/new-version-of-my-addin/</guid>
		<description><![CDATA[I just put a new version of my addin on my web site (for a first introduction see this post). Here are the major changes (apart from bug fixing):

Browse current file: Methods now show signatures
Browse current file: Generics shown correctly
Browse (all): Support of progress bar
Browse (all): Persistent window size
AddIn: first tests under Vista

There is currently an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=98&subd=ajdotnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img align="right" src="http://ajdotnet.files.wordpress.com/2007/03/browsecurrentfile.jpg" alt="BrowseCurrentFile.jpg" />I just put a new version of my addin on <a target="_blank" href="http://www.alexander-jung.net/download/download.htm">my web site</a> (for a first introduction see <a href="http://ajdotnet.wordpress.com/2006/12/16/its-christmas-time/">this post</a>). Here are the major changes (apart from bug fixing):</p>
<ul>
<li>Browse current file: Methods now show signatures</li>
<li>Browse current file: Generics shown correctly</li>
<li>Browse (all): Support of progress bar</li>
<li>Browse (all): Persistent window size</li>
<li>AddIn: first tests under Vista</li>
</ul>
<p>There is currently an issue under vista with language packs. Menu icons are not shown and shortcut keys are not assigned.</p>
<blockquote><p>Obviously MS has changed the loading scheme of the resource DLL &#8212; I need to fix that, once I get an idea how to do that). They also made the same mistake the once made with localized VBA languages (remember your VBA keywords being translated from IF-THEN-ELSE to WENN-DANN-SONST?). Now they translate the key codes (&#8220;Ctrl-Up Arrow&#8221; to &#8220;Strg-NACH-OBEN-TASTE&#8221;) as well as the commands. Can you believe that?</p>
<p>Anyway, I took care that the AddIn works, but nothing more. The missing icons are no vital part. Regarding shortcuts you need to assign them manually until I have fixed that issue. </p></blockquote>
<p>I think I have addressed some of the feedback I got (if only in the FAQ help page). Other feedback has been placed on my todo list (including flattened presentation, i.e. a list control rather than a tree control for browse).</p>
<p>I hope you enjoy it.</p>
<p><font color="#008000">That’s all for now folks,<br />
<strong>AJ.NET</strong></font><br />
<a href="http://www.dotnetkicks.com/kick/?url=http://ajdotnet.wordpress.com/2007/03/10/new-version-of-my-addin/"><img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2007/03/10/new-version-of-my-addin/" alt="kick it on DotNetKicks.com" /></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajdotnet.wordpress.com/98/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajdotnet.wordpress.com/98/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajdotnet.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajdotnet.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajdotnet.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajdotnet.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajdotnet.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajdotnet.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajdotnet.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajdotnet.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajdotnet.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajdotnet.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=98&subd=ajdotnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ajdotnet.wordpress.com/2007/03/10/new-version-of-my-addin/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/03b347f75b708670587fdbae73778116?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajdotnet</media:title>
		</media:content>

		<media:content url="http://ajdotnet.files.wordpress.com/2007/03/browsecurrentfile.jpg" medium="image">
			<media:title type="html">BrowseCurrentFile.jpg</media:title>
		</media:content>

		<media:content url="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2007/03/10/new-version-of-my-addin/" medium="image">
			<media:title type="html">kick it on DotNetKicks.com</media:title>
		</media:content>
	</item>
		<item>
		<title>It&#8217;s christmas time&#8230;</title>
		<link>http://ajdotnet.wordpress.com/2006/12/16/its-christmas-time/</link>
		<comments>http://ajdotnet.wordpress.com/2006/12/16/its-christmas-time/#comments</comments>
		<pubDate>Sat, 16 Dec 2006 20:52:14 +0000</pubDate>
		<dc:creator>ajdotnet</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[Software Developers]]></category>

		<guid isPermaLink="false">http://ajdotnet.wordpress.com/2006/12/16/its-christmas-time/</guid>
		<description><![CDATA[
&#8230; and Christmas means presents. Well, here&#8217;s my present for you:
I just finished a first version of my AddIn v2.0 for Visual Studio 2005. Its focus is on code navigation:

navigate C# code files with cursor keys, e.g. Ctrl-Down to go to the next type, method or whatever (something I got used to under Eclipse).
browse solution [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=76&subd=ajdotnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a target="_new" href="http://en.wikipedia.org/wiki/Image:Juletr%C3%A6et.jpg"><img align="right" width="215" src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Juletr%C3%A6et.jpg/215px-Juletr%C3%A6et.jpg" height="296" style="margin:0 0 5px 5px;" /></a></p>
<p>&#8230; and Christmas means presents. Well, here&#8217;s my present for you:</p>
<p>I just finished a first version of my <a href="http://www.alexander-jung.net/download/ajaddin2.zip">AddIn v2.0 for Visual Studio 2005</a>. Its focus is on code navigation:</p>
<ol>
<li>navigate C# code files with cursor keys, e.g. Ctrl-Down to go to the next type, method or whatever (something I got used to under Eclipse).</li>
<li>browse solution files or types and quickly jump to the one you need using filter criterions (similar to the respctive dialogs in ReSharper).</li>
</ol>
<p>There are more details in the readme and help file.</p>
<p>The addin has been tested by me and some friends and should be reasonably stable. It is however a first version and may have some bugs, in this case please sent me the stack trace from the output window.</p>
<p>Also I decided to get it out (in order to get feedback) as early as feasible rather than trying to do the 110% implementation. Therefore there is &#8220;room for improvement&#8221; in several areas (e.g. showing method signatures, browse inherritance hierarchy, and other stuff). Any comments and wishes regarding future development are welcome as well.</p>
<p><a target="_new" href="http://en.wikipedia.org/wiki/Image:Sydney_New_Year%27s_Eve_2.jpg"><img align="left" width="133" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Sydney_New_Year%27s_Eve_2.jpg/290px-Sydney_New_Year%27s_Eve_2.jpg" height="100" style="margin:0 5px 0 0;" /></a></p>
<p>Christmas also means even less time than usual; christmas dinners, visiting of relatives, etc. take their toll.</p>
<p>Since this is probably my last post for 2006 I wish you all a peacefull christmas and a happy new year.</p>
<p><font color="#008000">That&#8217;s all for now folks,<br />
<strong>AJ.NET</strong></font><br />
<a href="http://www.dotnetkicks.com/kick/?url=http://ajdotnet.wordpress.com/2006/12/16/its-christmas-time/"><img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2006/12/16/its-christmas-time/" /></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajdotnet.wordpress.com/76/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajdotnet.wordpress.com/76/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajdotnet.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajdotnet.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajdotnet.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajdotnet.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajdotnet.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajdotnet.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajdotnet.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajdotnet.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajdotnet.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajdotnet.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=76&subd=ajdotnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ajdotnet.wordpress.com/2006/12/16/its-christmas-time/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/03b347f75b708670587fdbae73778116?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajdotnet</media:title>
		</media:content>

		<media:content url="http://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Juletr%C3%A6et.jpg/215px-Juletr%C3%A6et.jpg" medium="image" />

		<media:content url="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Sydney_New_Year%27s_Eve_2.jpg/290px-Sydney_New_Year%27s_Eve_2.jpg" medium="image" />

		<media:content url="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2006/12/16/its-christmas-time/" medium="image" />
	</item>
		<item>
		<title>Got GAT?</title>
		<link>http://ajdotnet.wordpress.com/2006/12/02/got-gat/</link>
		<comments>http://ajdotnet.wordpress.com/2006/12/02/got-gat/#comments</comments>
		<pubDate>Sat, 02 Dec 2006 12:38:17 +0000</pubDate>
		<dc:creator>ajdotnet</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[Software Developers]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://ajdotnet.wordpress.com/2006/12/02/got-gat/</guid>
		<description><![CDATA[
I have been working with the Guidance Automation Toolkit (GAT) for some time now and thought I could give you a little motivation to look into it yourself.
What is GAT anyway?
GAT is a framework to build Visual Studio addins of a certain kind. Emphasis here is on the &#8216;G&#8217; in GAT, G like &#8220;Guidance&#8220;. GAT [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=75&subd=ajdotnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a target="_blank" href="http://en.wikipedia.org/wiki/Lego"><img align="right" width="180" src="http://upload.wikimedia.org/wikipedia/en/thumb/c/c4/Legobrick.jpg/180px-Legobrick.jpg" height="122" /></a></p>
<p>I have been working with the <a target="_blank" href="http://msdn.microsoft.com/vstudio/teamsystem/Workshop/gat/intro.aspx">Guidance Automation Toolkit (GAT)</a> for some time now and thought I could give you a little motivation to look into it yourself.</p>
<p><strong>What is GAT anyway?</strong></p>
<p>GAT is a framework to build Visual Studio addins of a certain kind. Emphasis here is on the &#8216;G&#8217; in GAT, G like &#8220;<em>Guidance</em>&#8220;. GAT makes it very easy to provide the user of the GAT package you developed (i.e. another developer) with templates, snippets, and most importantly with wizards and the ability to fullfill complex tasks. Typical usage scenarioas may include:</p>
<ul>
<li>Create a new class (boilerplate code), say an exception or form, based on user input (wizard), register it with some kind of configuration (complex task), enterprise library <a target="_blank" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/entlibjan2006_exceptionhandlingappblock.asp">exception handling</a> or <a target="_blank" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/uipab.asp">UIP application block</a>, and update the project structure accordingly, i.e. create the project entry, deal with SCC, etc. (again comlex task)</li>
<li>Create code based on some configuration or other information. E.g. generate standard web pages supporting display and <a target="_blank" href="http://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_delete">CRUD operations</a> on data, based on an existing dataset or XML schema.</li>
<li>Create your own wrapper class for some service description (like WSDL or other) that adresses special needs such as error handling or logging.</li>
</ul>
<p>In other words, use GAT &#8230;</p>
<ul>
<li>whenever you have to create a new code file that is boilerplate but requires a few parameters (a Wizard) and is a little too complex for code snippets.</li>
<li>whenever you have to create a family of related code files (as group, all or none), say a form and accompanying resource and configuration file.</li>
<li>whenever creating a new file requires addition work, like registering it in a central configuartion file</li>
<li>whenever work shall be triggered via context menu entries on project items</li>
<li>whenever these things span multiple projects or depend on project types</li>
<li>whenever these things need to be done &#8220;transactional&#8221;, i.e. support an undo mechanism</li>
</ul>
<p><strong>How does it work?</strong></p>
<p>GAT is a bit like <a target="_blank" href="http://en.wikipedia.org/wiki/Lego">Lego</a>. It&#8217;s a set of small building blocks of different type and for different purpose. There are references, type converters (<a href="http://ajdotnet.wordpress.com/2006/11/18/more-on-type-converters/">rings a bell</a>, doesn&#8217;t it? <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ), value providers, actions, all playing nicely together. Just like with Lego you have to know how the pices work together, not only where to fit them in but how to shape them into a working system. On the other hand, many of the components you will undoubtedly have to write tend to be very reusable &#8212; if you do it carefully &#8212; and quite often are unrelated to the specific task at hand. A recipe to update a config file for web applications? A type converter that provides a list of the web projects within the current solution &#8212; or better yet, it can be configured to show this or that kind of projects &#8212; has nothing to do with the special config file.</p>
<p>The place for assembling the pieces into a larger system is a central XML file in each GAT package. Here you describe logical units of work, called recipes. A recipe usually contains four major parts:</p>
<ul>
<li>infrastructure information, like in which menu the recipe will be available, which text and icon it will show.</li>
<li>arguments or rather data declaration. This is where &#8220;variables&#8221; are declared and associated with type converters and value providers</li>
<li>a wizard to get information from the user</li>
<li>a sequence of actions to do the actual work</li>
</ul>
<p>This set up reminds me a bit of <a target="_blank" href="http://en.wikipedia.org/wiki/COBOL">COBOL</a> file structure <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>The XML file may contain multiple recipes and it also has some global infrastructure information, like name or help file URL. There is also a special recipe called during the registration of the GAT package, used to register the other recipes. This registration employs a reference object that further decides whether the respective recipe will be available or not (e.g. one may check the current project type and only allow the menu entry in web projects).</p>
<p>Recipes may be the the major concept in GAT but it certainly does not stop here. GAT also includes template engines (solution, project, and file templates), packages may install code snippets, and it comes with a management component for the end user (the &#8220;Guidance Package Manager&#8221;).</p>
<p><strong>What can&#8217;t be done?</strong></p>
<p>Whatever you do plainly with GAT is available via GAT only and surfaced to the user mainly via menu entries on project items (with the exception of solution and project templates). The consequences:</p>
<ul>
<li>No way to react on anything but menu entries, especially not on other Visual Studio events, say starting a recipe automatically when saving a file. To accomplish that you&#8217;ll have to build a regular addin the hardcore way.</li>
<li>No way to use the actions somewhere else, in paritular no way to leverage them within the build process. MSBuild support or some command line tool would be more suited to that need.</li>
<li>GAT is also not exactly suited to work &#8220;within&#8221; a file, i.e. provide recipes that modifies a part of an existing code file, available depending on the current cursor location. Something like &#8220;<em>Implement Interface</em>&#8221; or &#8220;<em>Encapsulate Field</em>&#8221; in the context menu depending on whether you are at the location of an interface or a field. Again this would be better done within a regular addin. (Fortunatelly someone within Microsoft allready thought of the examples I just mentioned&#8230;)</li>
</ul>
<p>It is not as if GAT is out of question in these cases. It just won&#8217;t solve all requirements and you need to carefully plan a layered implementation approach. Put core functionality in a Core.DLL and call it from a GAT action as well as from your favourite command line tool.</p>
<p><a target="_blank" href="http://en.wikipedia.org/wiki/...Famous_Last_Words…"><strong>Famous last words&#8230;</strong></a></p>
<p>Well, it has to be said: GAT is only a Technology Preview right now. It&#8217;s quite stable and fairly complete, but some things may need some improvement (user fedback in error cases, SCC awareness, shortcommings of existing components). Another issue is the documentation which is better than one would expect but still needs a good deal of improvement. And of course noone knows whether the next release will break existing code and no final release date has been announced yet.</p>
<p>Anyway, if the above description of GAT sounds like something you have been looking for I recommend to give it a try. For those interested: there is a <a target="_blank" href="http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=78">forum</a> in which you will even get feedback from the authors and a dedicated <a target="_blank" href="http://guidanceautomation.net/">GAT web site</a> which also has sample code.</p>
<p><font color="#008000">That&#8217;s all for now folks,<br />
<strong>AJ.NET </strong></font><br />
<a href="http://www.dotnetkicks.com/kick/?url=http://ajdotnet.wordpress.com/2006/12/02/got-gat/"><img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2006/12/02/got-gat/" /></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajdotnet.wordpress.com/75/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajdotnet.wordpress.com/75/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajdotnet.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajdotnet.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajdotnet.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajdotnet.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajdotnet.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajdotnet.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajdotnet.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajdotnet.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajdotnet.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajdotnet.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=75&subd=ajdotnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ajdotnet.wordpress.com/2006/12/02/got-gat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/03b347f75b708670587fdbae73778116?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajdotnet</media:title>
		</media:content>

		<media:content url="http://upload.wikimedia.org/wikipedia/en/thumb/c/c4/Legobrick.jpg/180px-Legobrick.jpg" medium="image" />

		<media:content url="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2006/12/02/got-gat/" medium="image" />
	</item>
		<item>
		<title>Phantom property values</title>
		<link>http://ajdotnet.wordpress.com/2006/11/24/phantom-property-values/</link>
		<comments>http://ajdotnet.wordpress.com/2006/11/24/phantom-property-values/#comments</comments>
		<pubDate>Fri, 24 Nov 2006 21:40:55 +0000</pubDate>
		<dc:creator>ajdotnet</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://ajdotnet.wordpress.com/2006/11/24/phantom-property-values/</guid>
		<description><![CDATA[Here&#8217;s a quick tip for design time coders: Suppose you had a control or component and you would want to change a design time property from your code (say as reaction to a designer verb or the change of another property). Something like the following:
[ToolboxData("&#60;{0}:PropertyTextBox runat=server /&#62;")]
public class PropertyTextBox : TextBox
{
    public string StandardCss { &#8230; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=73&subd=ajdotnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Here&#8217;s a quick tip for design time coders: Suppose you had a control or component and you would want to change a design time property from your code (say as reaction to a designer verb or the change of another property). Something like the following:</p>
<blockquote><p>[ToolboxData(<font color="#800000">"&lt;{0}:PropertyTextBox runat=server /&gt;"</font>)]<br />
<font color="#0000ff">public</font> <font color="#0000ff">class</font> PropertyTextBox : TextBox<br />
{<br />
    <font color="#0000ff">public</font> <font color="#0000ff">string</font> StandardCss { &#8230; }<br />
    <font color="#0000ff">public</font> <font color="#0000ff">string</font> ErrorCss { &#8230; }<br />
    <br />
    <font color="#0000ff">bool</font> _noCssHandling;<br />
    <font color="#0000ff">public</font> <font color="#0000ff">bool</font> NoCssHandling<br />
    {<br />
        <font color="#0000ff">get</font> { <font color="#0000ff">return</font> _noCssHandling; }<br />
        <font color="#0000ff">set</font><br />
        {<br />
            _noCssHandling = <font color="#0000ff">value</font>;<br />
            <font color="#0000ff">if</font> (_noCssHandling)<br />
            {<br />
                _standardCss = <font color="#800000">&#8220;&#8221;</font>;<br />
                _errorCss = <font color="#800000">&#8220;&#8221;</font>;<br />
            }<br />
        }<br />
    }<br />
}</p></blockquote>
<p>Looks good? OK. Put it on your page, switch to design view, go to the property dialog, and change the two string members. Now switch to code view and you&#8221;ll see the respective attributes in the contol tag:</p>
<blockquote><p><font color="#0000ff">&lt;<font color="#800000">cc1</font>:<font color="#800000">PropertyTextBox</font> <font color="#ff0000">ID</font>=&#8221;PropertyTextBox1&#8243; <font color="#ff0000">runat</font>=&#8221;server&#8221; <font color="#ff0000">ErrorCss</font>=&#8221;TextBoxError1&#8243; <font color="#ff0000">StandardCss</font>=&#8221;TextBox1&#8243;/&gt;</font></p></blockquote>
<p>Looks still good? OK. Switch to design view, change the property <em>NoCssHandling </em>to <em>true</em>, and enjoy the fact that the other two properties are miraculously set to empty.</p>
<p>Looks still good? Still content? Well, just for the fun of it switch to code view&#8230;</p>
<blockquote><p><font color="#0000ff">&lt;<font color="#800000">cc1</font>:<font color="#800000">PropertyTextBox</font> <font color="#ff0000">ID</font>=&#8221;PropertyTextBox1&#8243; <font color="#ff0000">runat</font>=&#8221;server&#8221; <font color="#ff0000">ErrorCss</font>=&#8221;TextBoxError1&#8243; <font color="#ff0000">NoCssHandling</font>=&#8221;True&#8221; <font color="#ff0000">StandardCss</font>=&#8221;TextBox1&#8243;/&gt;</font></p></blockquote>
<p>Wait a moment! Empty strings are not supposed to contain old values, right? You could even debug the code and verify that the dependend properties have been set and returned the correct values. And yet, within the markup code of your .aspx file the repective HTML attributes remain unchanged.</p>
<p><strong>Catching the phantom</strong></p>
<p>The reason for this effect is &#8230; I <em>may</em> have mentioned that before <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  &#8230; design time is different. At runtime you have only one instance of your object. At design time there may be phantoms, ghosts and astral bodies &#8211; different incarnations of the same object, shadows that reflect different time spans. There is but one file, but what you see is just one of possibly many presentations of that file in the appearance in which the current designer presents it. This may be the .aspx markup view, the design surface, the property dialog, the code view, the component view.</p>
<p>If one designer triggers a change on your object, none of the other designers knows about it. And thus, none will reflect that change, leaving the different designers in an inconsistent state. The trick is to announce the change to the other designers and the means to do that is the <em>IComponentChangeService </em>interface. (This is something you would only want to happen at design time to avoid unexpected behaviour at runtime.)</p>
<p>BTW: This is called Document/View concept, a derivation of the Model/View/Controller pattern and well known from MFC. No fairies or other surreal creatures. No <a target="_blank" href="http://en.wikipedia.org/wiki/Leprachaun">leprechauns</a> either, what a pity.)</p>
<p>Here is a version that takes the design time requirements into account: </p>
<blockquote><p><font color="#0000ff">public</font> <font color="#0000ff">bool</font> NoCssHandling<br />
{<br />
    <font color="#0000ff">get</font> { <font color="#0000ff">return</font> _noCssHandling; }<br />
    <font color="#0000ff">set</font><br />
    {<br />
        _noCssHandling = <font color="#0000ff">value</font>;<br />
        <font color="#0000ff">if</font> (_noCssHandling)<br />
        {<br />
            <font color="#0000ff">if</font> ((<font color="#0000ff">this</font>.Site != <font color="#0000ff">null</font>) &amp;&amp; (<font color="#0000ff">this</font>.Site.DesignMode))<br />
            {<br />
                SetValue(<font color="#0000ff">this</font>, GetPropertyDescriptor(<font color="#0000ff">this</font>, <font color="#800000">&#8220;StandardCss&#8221;</font>), <font color="#800000">&#8220;&#8221;</font>);<br />
                SetValue(<font color="#0000ff">this</font>, GetPropertyDescriptor(<font color="#0000ff">this</font>, <font color="#800000">&#8220;ErrorCss&#8221;</font>), <font color="#800000">&#8220;&#8221;</font>);<br />
            }<br />
            <font color="#0000ff">else</font><br />
            {<br />
                _standardCss = <font color="#800000">&#8220;&#8221;</font>;<br />
                _errorCss = <font color="#800000">&#8220;&#8221;</font>;<br />
            }<br />
        }<br />
    }<br />
}</p>
<p><font color="#0000ff">static</font> PropertyDescriptor GetPropertyDescriptor(IComponent component, <font color="#0000ff">string</font> property)<br />
{<br />
    PropertyDescriptorCollection properties =<br />
        TypeDescriptor.GetProperties(component.GetType());<br />
    <font color="#0000ff">foreach</font> (PropertyDescriptor pd <font color="#0000ff">in</font> properties)<br />
    {<br />
        <font color="#0000ff">if</font> (pd.Name == property)<br />
        <font color="#0000ff">return</font> pd;<br />
    }<br />
    <font color="#0000ff">return</font> <font color="#0000ff">null</font>;<br />
}</p>
<p><font color="#0000ff">static</font> <font color="#0000ff">void</font> SetValue(IComponent component, PropertyDescriptor pd, <font color="#0000ff">object</font> <font color="#0000ff">value</font>)<br />
{<br />
    <font color="#0000ff">object</font> oldValue = <font color="#0000ff">null</font>;<br />
    IComponentChangeService componentChangeService = (IComponentChangeService)<br />
        component.Site.GetService(<font color="#0000ff">typeof</font>(IComponentChangeService));<br />
    <br />
    <font color="#0000ff">if</font> (componentChangeService != <font color="#0000ff">null</font>)<br />
    {<br />
        <font color="#0000ff">try</font><br />
        {<br />
            <font color="#008000"><em>// rememeber old value</em></font><br />
            oldValue = pd.GetValue(component);<br />
            <font color="#008000"><em>// announce before change</em></font><br />
            componentChangeService.OnComponentChanging(component, pd);<br />
        }<br />
        <font color="#0000ff">catch</font> (CheckoutException ex)<br />
        {<br />
            <font color="#008000"><em>// under source control, the checkout may be canceled by the user</em></font><br />
            <font color="#0000ff">if</font> (ex != CheckoutException.Canceled)<br />
                <font color="#0000ff">throw</font>;<br />
        }<br />
    }<br />
    <br />
    <font color="#0000ff">try</font><br />
    {<br />
        <font color="#008000"><em>// try to set new value</em></font><br />
        pd.SetValue(component, <font color="#0000ff">value</font>);<br />
    }<br />
    <font color="#0000ff">catch</font><br />
    {<br />
        <font color="#0000ff">value</font> = oldValue;<br />
        <font color="#0000ff">throw</font>;<br />
    }<br />
    <font color="#0000ff">finally</font><br />
    {<br />
        <font color="#008000"><em>// announce after change</em></font><br />
        <font color="#0000ff">if</font> (componentChangeService != <font color="#0000ff">null</font>)<br />
            componentChangeService.OnComponentChanged(component, pd, oldValue, <font color="#0000ff">value</font>);<br />
    }<br />
}</p></blockquote>
<p>Well, that&#8217;s fairly much code just to set a property value. And to announce it to the design time environment. And to take source control and other effects into account. And it&#8217;s not even property specific? Wow. Reusable and a good candidate for a helper class. Not much code if you really think about it.</p>
<p>From now on, your property value changes at design time will be properly advertised to all designers and they will happily reflect those changed values.</p>
<p><font color="#008040">That&#8217;s all for now folks,<br />
<strong>AJ.NET</strong></font><br />
<a href="http://www.dotnetkicks.com/kick/?url=http://ajdotnet.wordpress.com/2006/11/24/phantom-property-values/"><img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2006/11/24/phantom-property-values/" /></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajdotnet.wordpress.com/73/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajdotnet.wordpress.com/73/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajdotnet.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajdotnet.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajdotnet.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajdotnet.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajdotnet.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajdotnet.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajdotnet.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajdotnet.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajdotnet.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajdotnet.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=73&subd=ajdotnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ajdotnet.wordpress.com/2006/11/24/phantom-property-values/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/03b347f75b708670587fdbae73778116?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajdotnet</media:title>
		</media:content>

		<media:content url="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2006/11/24/phantom-property-values/" medium="image" />
	</item>
		<item>
		<title>More (on) type converters</title>
		<link>http://ajdotnet.wordpress.com/2006/11/18/more-on-type-converters/</link>
		<comments>http://ajdotnet.wordpress.com/2006/11/18/more-on-type-converters/#comments</comments>
		<pubDate>Sat, 18 Nov 2006 14:15:25 +0000</pubDate>
		<dc:creator>ajdotnet</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://ajdotnet.wordpress.com/2006/11/18/more-on-type-converters/</guid>
		<description><![CDATA[After the last post I thought I might come up with some real world examples. Just to give you an idea how usefull type converters can be at design time.
Configured lists
There are various situations where a string property should be set to a value from a given set (if only non-exclusive default values to speed [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=72&subd=ajdotnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>After the last <a href="http://ajdotnet.wordpress.com/2006/11/11/reach-out-at-design-time/">post</a> I thought I might come up with some real world examples. Just to give you an idea how usefull type converters can be at design time.</p>
<p><strong>Configured lists</strong></p>
<p>There are various situations where a string property should be set to a value from a given set (if only non-exclusive default values to speed up typing), the set being (made) available in some kind of configuration file. Examples I encountered so far include:</p>
<ul>
<li>appSettings keys</li>
<li>navigation graph information for the <a target="_blank" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/uip.asp">User Interface Process (UIP) Application Block</a></li>
<li>named permissions on buttons</li>
<li>standard IDs for textboxes, buttons, etc.</li>
</ul>
<p>In this case a type converter that reads an the web.config and returns the /configuration/appSettings/add/@key values solves the first demand. The step to a type converter base class that reads any xml file and provides a list of values according to some XPath expression is no rocket science. Given that base class any of those examples can be implemented using a simple derived class that only has to specify the file and XPath.</p>
<p><strong>Artificial Enumerations </strong></p>
<p>Consider the following (quite common) situation: You have an enumeration of certain values for some property of your component. The component shall act as base class and will be extended in different contexts. For example, a database action enumeration could include values like <em>Save</em>, <em>Delete </em>and <em>Update</em>.<br />
The first approach that comes to mind would be to define a C# enumeration and the respective property. Afterwards your property can be set in the properties pane, the pane will automatically present a drop down list of the enumeration values, not allowing any other input. Of course working on the code level with eumerations is type safe and supported with intellisense.</p>
<p>However there is also a serious issue: The set of valid values for that property cannot be extended. .NET does not support something like inherritance of enumerations. If the derived class should need additional values one could either provide some special enumeration value in the base class for future use (some kind of &#8220;Custom&#8221;) and add an additional property to describe that custom value (making the act of describing the database action a two-stage process), or extend the enumeration with the custom value itself (spoiling the base class with information of derived functionality, making it visible to any other derived class and causing maintenance hurdles).</p>
<p>One could also revert to using a string instead of an enumeration. This would allow free choice of values and keep the base class clean of special cases. On the down side would be the lack of design time support, intellisense support (this could be solved with constants, yet this doesn&#8217;t help within the designer), and the need to remember all valid values in a given context. I see typos having a party&#8230;</p>
<p>Frankly, if these are the alternatives, I would prefer the spoiled enumeration.</p>
<p>However, a TypeConverter can help with these issues:<br />
First, some attributes could describe the valid values of a property (they have to be specified somehow and an attribute looks good for me). A derived class could use one of these attributes to extend the set defined by the base class (say an attribute at the class level could take the name of the property and the additional values).<br />
A type converter could then examine the property (the information is available through the context parameter) and the respective attributes along the inherritance hierarchy to build up a list of values which in turn causes the property grid to show a drop down list at design time. What&#8217;s more, the list will vary depending on the context, showing only the values that make sense in the given situation. Voilá, a string property with &#8220;extendable enumeration behaviour&#8221; at runtime.</p>
<p><strong>Reflection information</strong></p>
<p>Sometimes one needs to specify types (for dynamically created objects), methods (to be invoked dynamically), or properties (to get data from). All respective candidates (say all properties of an object) can be made available at designtime, given the right type converter.</p>
<p><strong>Solution or project information</strong></p>
<p>For navigation to another page it would be usefull to have a list of .aspx files in your project to select the page at design time. A type converter could get this list using the Visual Studio automation model.<br />
This area is especially usefull if you are working with the <a target="_blank" href="http://msdn2.microsoft.com/en-us/teamsystem/aa718948.aspx">Guidance Automation Toolkit (GAT)</a> where type converters play a role in providing and converting informations for and from wizards. Examples include a list of projects, base classes, or the conversion of a project folder to a respective namespace for a new class.</p>
<p><strong>Real type conversion</strong></p>
<p>We should not forget the function type converters have by name. If you have a look at a windows form control at design time (the windows forms designer seems to make better use of this than the webforms designer), you will notice that you can type in something like &#8220;75;50&#8243; in the properties pane for the Size property. You may also click on the little + and set the Width and Height property directly. The ability to set the values of contained properties (in this case Width and Height) on the object itself (in this case Size) comes with a &#8230; guess what? &#8230; type converter. In this case it converts the string with two numbers to an instance of the Size struct and vice versa.<br />
Thus type converters can help to simplify the modification of properties of complex structs.</p>
<p>Code? Sorry, not this time. These are all real world examples from actual projects. I can share knowledge and experience but not customers&#8217; code.</p>
<p><font color="#008000">That&#8217;s all for now folks,<br />
<strong>AJ.NET</strong></font><br />
<a href="http://www.dotnetkicks.com/kick/?url=http://ajdotnet.wordpress.com/2006/11/18/more-on-type-converters/"><img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2006/11/18/more-on-type-converters/" /></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajdotnet.wordpress.com/72/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajdotnet.wordpress.com/72/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajdotnet.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajdotnet.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajdotnet.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajdotnet.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajdotnet.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajdotnet.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajdotnet.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajdotnet.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajdotnet.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajdotnet.wordpress.com/72/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajdotnet.wordpress.com&blog=305378&post=72&subd=ajdotnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ajdotnet.wordpress.com/2006/11/18/more-on-type-converters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/03b347f75b708670587fdbae73778116?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajdotnet</media:title>
		</media:content>

		<media:content url="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://ajdotnet.wordpress.com/2006/11/18/more-on-type-converters/" medium="image" />
	</item>
	</channel>
</rss>