﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
  <channel>
    <title>instantiate</title>
    <description>two apples... both instantiate the single universal redness</description>
    <link>http://instantiate.co.nz/</link>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>BlogEngine.NET 1.6.1.0</generator>
    <language>en-US</language>
    <blogChannel:blogRoll>http://instantiate.co.nz/opml.axd</blogChannel:blogRoll>
    <blogChannel:blink>http://feeds.feedburner.com/Instantiate</blogChannel:blink>
    <dc:creator>Luke Ryan</dc:creator>
    <dc:title>instantiate</dc:title>
    <geo:lat>0.000000</geo:lat>
    <geo:long>0.000000</geo:long>
    <item>
      <title>System Center Operations Manager Powershell Modules - An Error Handling Strategy</title>
      <description>&lt;p&gt;Lately I've been involved with SCOM 2007 R2 custom management pack development. We have been using quite a lot of powershell, primarily using the Microsoft.Windows.PowerShellPropertyBagProbe. Today I noticed however that sometimes if a powershell script fails in a workflow, SCOM silently swallows the output to the error pipeline and continues. No 22406 "The PowerShell script failed with the below exception" events in the Operations Manager event log, nothing.&lt;/p&gt;
&lt;p&gt;As we want to know if our powershell scripts fail, it seems prudent that we should implement our own error handling and logging. The following script template provides base logging functionality, logging to the Operations Manager event log via the SCOM COM ScriptAPI. The two provided parameters $logErrors and $logDebug can be set as overridable in the workflow, allowing operator customisation of the level of logging.&lt;/p&gt;
&lt;p&gt;&lt;code&gt; param([int]$logErrors, [int]$logDebug)  &lt;br /&gt;&lt;br /&gt;$Script:scriptname = $MyInvocation.MyCommand.Name; &lt;br /&gt;$Script:api = New-Object -comObject 'MOM.ScriptAPI' &lt;br /&gt;$Script:bag = $api.CreatePropertyBag() &lt;br /&gt;&lt;br /&gt; function LogError([string] $msg) &lt;br /&gt;{  &lt;br /&gt;if($logErrors) &lt;br /&gt;{ &lt;br /&gt;Write-Host $msg; &lt;br /&gt;$Script:api.LogScriptEvent($Script:scriptname, 100, 1, $msg); &lt;br /&gt;}  &lt;br /&gt;}  &lt;br /&gt;&lt;br /&gt;function LogInformation([string] $msg) &lt;br /&gt;{  &lt;br /&gt;if($logDebug) &lt;br /&gt;{ &lt;br /&gt;Write-Host $msg; &lt;br /&gt;$Script:api.LogScriptEvent($Script:scriptname, 101, 4, $msg);&lt;br /&gt;}  &lt;br /&gt;}  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#Your Script here  &lt;br /&gt;&lt;br /&gt;trap [SystemException] &lt;br /&gt;{  &lt;br /&gt;LogError($_.Exception.ToString());&lt;br /&gt;continue;  &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;$Script:bag &lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Monitoring the monitoring!&lt;/strong&gt;&lt;br /&gt;From here it is fairly straight forward to create a rule or monitor workflow that detects the events from the event log and alerts on the health of all powershell scripts running in monitoring workflows.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
      <link>http://instantiate.co.nz/post/System-Center-Operations-Manager-Powershell-An-Error-Handling-Strategy.aspx</link>
      <author>Luke</author>
      <comments>http://instantiate.co.nz/post/System-Center-Operations-Manager-Powershell-An-Error-Handling-Strategy.aspx#comment</comments>
      <guid>http://instantiate.co.nz/post.aspx?id=770aa78a-f059-4bae-8896-aa28521798f2</guid>
      <pubDate>Wed, 02 Nov 2011 14:59:00 +2200</pubDate>
      <category>Blog</category>
      <dc:publisher>Luke</dc:publisher>
      <pingback:server>http://instantiate.co.nz/pingback.axd</pingback:server>
      <pingback:target>http://instantiate.co.nz/post.aspx?id=770aa78a-f059-4bae-8896-aa28521798f2</pingback:target>
      <slash:comments>71</slash:comments>
      <trackback:ping>http://instantiate.co.nz/trackback.axd?id=770aa78a-f059-4bae-8896-aa28521798f2</trackback:ping>
      <wfw:comment>http://instantiate.co.nz/post/System-Center-Operations-Manager-Powershell-An-Error-Handling-Strategy.aspx#comment</wfw:comment>
      <wfw:commentRss>http://instantiate.co.nz/syndication.axd?post=770aa78a-f059-4bae-8896-aa28521798f2</wfw:commentRss>
    </item>
    <item>
      <title>Creating a XAML Windows Phone style loading animation</title>
      <description>&lt;p&gt;
&lt;script src="http://instantiate.co.nz/Silverlight/Silverlight.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;/p&gt;
&lt;p&gt;I've been doing more and more XAML development lately, and have recently traded my iPhone for a Windows Phone. One WPF application that I've been working on has a &lt;a href="http://en.wikipedia.org/wiki/Metro_%28design_language%29"&gt;Metro&lt;/a&gt; design feel to it but had a plain loading screen. I created an animation with 5 animated rectangles like the Windows Phone loading animation, which was surprisingly easy.&lt;/p&gt;
&lt;div id="silverlightControlHost"&gt;
&lt;object width="100%" height="30" data="data:application/x-silverlight-2," type="application/x-silverlight-2"&gt;
&lt;param name="source" value="http://instantiate.co.nz/Silverlight/WP7LoadingSample.xap" /&gt;
&lt;param name="background" value="white" /&gt;
&lt;param name="minRuntimeVersion" value="4.0.60310.0" /&gt;
&lt;param name="autoUpgrade" value="true" /&gt; &lt;a style="text-decoration:none" href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=4.0.60310.0"&gt; &lt;img style="border-style:none" src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" /&gt; &lt;/a&gt;
&lt;/object&gt;
&lt;/div&gt;
&lt;p&gt;I created the animation on a Rectangle element using blend, I used keyframes as the animation changes speed as it moves across the screen. The resulting XAML was:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;span&gt;&amp;lt;UserControl x:Class="LoadingRectangle" xmlns="&lt;a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation" target="_blank"&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation&lt;/a&gt;" xmlns:x="&lt;a href="http://schemas.microsoft.com/winfx/2006/xaml" target="_blank"&gt;http://schemas.microsoft.com/winfx/2006/xaml&lt;/a&gt;" xmlns:mc="&lt;a href="http://schemas.openxmlformats.org/markup-compatibility/2006" target="_blank"&gt;http://schemas.openxmlformats.org/markup-compatibility/2006&lt;/a&gt;" xmlns:d="&lt;a href="http://schemas.microsoft.com/expression/blend/2008" target="_blank"&gt;http://schemas.microsoft.com/expression/blend/2008&lt;/a&gt;" mc:Ignorable="d" d:DesignHeight="6" d:DesignWidth="900 Background="{x:Null}"&amp;gt;&lt;/span&gt;&amp;nbsp; &lt;span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt; &amp;lt;Grid&amp;gt;&lt;/span&gt; &lt;span&gt;&amp;nbsp;&lt;/span&gt; &lt;span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;Grid.ColumnDefinitions&amp;gt;&lt;/span&gt; &lt;span&gt;&amp;nbsp;&lt;/span&gt; &lt;span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;/Grid.ColumnDefinitions&amp;gt;&lt;/span&gt; &lt;span&gt;&amp;nbsp;&lt;/span&gt; &lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;Rectangle x:Name="Rectangle" Fill="White" Height="6" Width="6" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left"&amp;gt;&lt;/span&gt; &lt;span&gt;&amp;nbsp;&lt;/span&gt; &lt;span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;Rectangle.Triggers&amp;gt;&lt;/span&gt; &lt;span&gt;&amp;nbsp;&lt;/span&gt; &lt;span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;EventTrigger RoutedEvent="Rectangle.Loaded"&amp;gt;&lt;/span&gt; &lt;span&gt;&amp;nbsp;&lt;/span&gt; &lt;span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;BeginStoryboard&amp;gt;&lt;/span&gt; &lt;span&gt;&amp;nbsp;&lt;/span&gt; &lt;span&gt;&amp;nbsp;&lt;/span&gt; &lt;span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;Storyboard RepeatBehavior="Forever"&amp;gt;&lt;/span&gt; &lt;span&gt;&amp;nbsp;&lt;/span&gt; &lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="rectangle"&lt;/span&gt;&amp;gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;EasingDoubleKeyFrame x:Name="KeyFrame1" KeyTime="0" Value="-10"/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;EasingDoubleKeyFrame x:Name="KeyFrame2" KeyTime="0:0:1" Value="330"/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;EasingDoubleKeyFrame x:Name="KeyFrame3" KeyTime="0:0:4" Value="660"/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;EasingDoubleKeyFrame x:Name="KeyFrame4" KeyTime="0:0:5" Value="1000"/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;EasingDoubleKeyFrame x:Name="KeyFrame5" KeyTime="0:0:6" Value="1000"/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;/DoubleAnimationUsingKeyFrames&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;/Storyboard&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;/BeginStoryboard&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;/EventTrigger&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;/Rectangle.Triggers&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;Rectangle.RenderTransform&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;TransformGroup&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;ScaleTransform/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;SkewTransform/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;RotateTransform/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;TranslateTransform/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;/TransformGroup&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;/Rectangle.RenderTransform&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;/Rectangle&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;/Grid&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;lt;/UserControl&amp;gt;&lt;/span&gt; &lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The DoubleAnimationUsingKeyFrames allows you to specify where the element will be in pixels at a given time. It then smoothly animates the transition between these points, allowing for the changes in speed. This works for a fixed screen size of 1000px but a render transform like this can only take explicit values which isn't great if the size of the control can vary at runtime (fluid layout). We want our loading animation to fill the whole screen, not appear halfway across the middle! To work around this I added x:Name attributes to the animation KeyFrame elements so that I could refer to them in code (I know, not perfect) and set the width in the&amp;nbsp;SizeChanged event of the parent control. This way if the parent control has its width explicitly set or if it defaults to filling its parent (in my case the WPF Window, in the case above the div container) then the animation will be relative.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Manually set the values for the animation when the window size is changed so the &lt;br /&gt;/// rectangle is animated across the whole screen. &lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="sender"&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name="e"&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;private void LoadingRectangle_SizeChanged(object sender, SizeChangedEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; if (e.WidthChanged)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KeyFrame2.Value = this.ActualWidth / 3;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KeyFrame3.Value = KeyFrame2.Value * 2;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KeyFrame4.Value = this.ActualWidth + 10;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KeyFrame5.Value = this.ActualWidth + 10;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Finally I added a property for delay in seconds, so that many of these controls can be used together and triggered at the same time, but appear slightly staggered - Windows Phone 7 has five rectangles that animate one after the other.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt; /// The number of seconds from the control being loaded that the animation should  &lt;br /&gt;/// be offset. This defaults to zero, meaning the animation will start as soon as  &lt;br /&gt;/// the control is loaded.&lt;br /&gt; /// &amp;lt;/summary&amp;gt; &lt;br /&gt; public double OffsetSeconds&lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp; get&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return this.OffsetSecondsValue;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.OffsetSecondsValue = value; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.OffsetKeyFrameKeyTimes(); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;gt; &lt;br /&gt;/// Offsets the four keyframes of the animation with the set offset value. This &lt;br /&gt; /// allows rectangles to be visually staggered if more than one are being used together. &lt;br /&gt;/// &amp;lt;/summary&amp;gt; &lt;br /&gt;private void OffsetKeyFrameKeyTimes() &lt;br /&gt;{&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TimeSpan offset = TimeSpan.FromSeconds(OffsetSeconds);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;KeyFrame1.KeyTime = KeyFrame1.KeyTime.TimeSpan.Add(offset);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;KeyFrame2.KeyTime = KeyFrame2.KeyTime.TimeSpan.Add(offset);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;KeyFrame3.KeyTime = KeyFrame3.KeyTime.TimeSpan.Add(offset);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;KeyFrame4.KeyTime = KeyFrame4.KeyTime.TimeSpan.Add(offset);&lt;br /&gt;}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The final XAML to have five rectangles working together looks like this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;LoadingRectangle OffsetSeconds="0.0" /&amp;gt;&lt;br /&gt;&amp;lt;LoadingRectangle OffsetSeconds="0.2" /&amp;gt;&lt;br /&gt;&amp;lt;LoadingRectangle OffsetSeconds="0.4" /&amp;gt;&lt;br /&gt;&amp;lt;LoadingRectangle OffsetSeconds="0.6" /&amp;gt;&lt;br /&gt; &amp;lt;LoadingRectangle OffsetSeconds="0.8" /&amp;gt;&lt;/code&gt;&lt;/p&gt;</description>
      <link>http://instantiate.co.nz/post/Creating-a-XAML-Windows-Phone-style-loading-animation.aspx</link>
      <author>Luke</author>
      <comments>http://instantiate.co.nz/post/Creating-a-XAML-Windows-Phone-style-loading-animation.aspx#comment</comments>
      <guid>http://instantiate.co.nz/post.aspx?id=e28e4350-dac3-4c33-ba1c-ac2b6b122432</guid>
      <pubDate>Wed, 24 Aug 2011 16:10:00 +2200</pubDate>
      <category>Blog</category>
      <dc:publisher>Luke</dc:publisher>
      <pingback:server>http://instantiate.co.nz/pingback.axd</pingback:server>
      <pingback:target>http://instantiate.co.nz/post.aspx?id=e28e4350-dac3-4c33-ba1c-ac2b6b122432</pingback:target>
      <slash:comments>203</slash:comments>
      <trackback:ping>http://instantiate.co.nz/trackback.axd?id=e28e4350-dac3-4c33-ba1c-ac2b6b122432</trackback:ping>
      <wfw:comment>http://instantiate.co.nz/post/Creating-a-XAML-Windows-Phone-style-loading-animation.aspx#comment</wfw:comment>
      <wfw:commentRss>http://instantiate.co.nz/syndication.axd?post=e28e4350-dac3-4c33-ba1c-ac2b6b122432</wfw:commentRss>
    </item>
    <item>
      <title>Moving on to the UK</title>
      <description>&lt;p&gt;I've left &lt;a href="http://www.intergen.co.nz"&gt;Intergen &lt;/a&gt;Wellington to&amp;nbsp; pursue personal and professional growth overseas. It's not easy leaving a place that feels like home, with a staff that feel like family. I'm incredibly greatful for the time I've spent with Intergen, they are an amazing company. I hope I will see them again in the future :-)&lt;/p&gt;
&lt;p&gt;I'm currently in Singapore en-route for the UK where I will be looking for a .NET role. In the mean time posts to this blog will be irregular, but you can follow my travels at &lt;a href="http://journeys.instantiate.co.nz"&gt;journeys.instantiate.co.nz&lt;/a&gt;.&lt;/p&gt;</description>
      <link>http://instantiate.co.nz/post/Moving-on-to-the-UK.aspx</link>
      <author>Luke</author>
      <comments>http://instantiate.co.nz/post/Moving-on-to-the-UK.aspx#comment</comments>
      <guid>http://instantiate.co.nz/post.aspx?id=7043ab3a-748f-45a8-a0a6-4ab781f29c78</guid>
      <pubDate>Tue, 03 May 2011 11:18:00 +2200</pubDate>
      <category>Blog</category>
      <dc:publisher>Luke</dc:publisher>
      <pingback:server>http://instantiate.co.nz/pingback.axd</pingback:server>
      <pingback:target>http://instantiate.co.nz/post.aspx?id=7043ab3a-748f-45a8-a0a6-4ab781f29c78</pingback:target>
      <slash:comments>67</slash:comments>
      <trackback:ping>http://instantiate.co.nz/trackback.axd?id=7043ab3a-748f-45a8-a0a6-4ab781f29c78</trackback:ping>
      <wfw:comment>http://instantiate.co.nz/post/Moving-on-to-the-UK.aspx#comment</wfw:comment>
      <wfw:commentRss>http://instantiate.co.nz/syndication.axd?post=7043ab3a-748f-45a8-a0a6-4ab781f29c78</wfw:commentRss>
    </item>
    <item>
      <title>Demoware vs Enterprise Applications</title>
      <description>&lt;p&gt;During my typical commute earlier in the week I was browsing through my RSS feed as I often do.&amp;nbsp;&lt;span&gt;I  stumbled upon &lt;a href="http://blogs.msdn.com/b/adonet/archive/2011/03/08/ef-feature-ctp5-code-first-model-with-master-detail-wpf-application.aspx"&gt;this post&lt;/a&gt; about Code First Entity Framework 4  development. Great I thought, this sounds good. I wonder if Code First will be a good choice for my next project. Unfortunately rather than the useful post about the details of  the new Code First EF features I was looking for, I got demoware  101: how to build something rubbish really quickly!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This  got me wondering if Microsoft do provide any guidance around building  enterprise scale applications. I was pleasantly surprised to find the &lt;a href="http://apparchguide.codeplex.com/"&gt;.NET Application Architecture Guide&lt;/a&gt; on the patterns and practices codeplex site. It's not a quick read but so far I'm really enjoying it and  recommend reading it. You can get it &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ce40e4e1-9838-4c89-a197-a373b2a60df2&amp;amp;displaylang=en"&gt;here&lt;/a&gt; from MSDN as a free PDF download.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://instantiate.co.nz/image.axd?picture=2011%2f3%2fmicrosoftapplicationarchitectureguide.jpg" alt="" /&gt;&lt;/p&gt;</description>
      <link>http://instantiate.co.nz/post/I-get-fed-up-with-demoware-and-stumble-across-the-NET-Application-Architecture-Guide.aspx</link>
      <author>Luke</author>
      <comments>http://instantiate.co.nz/post/I-get-fed-up-with-demoware-and-stumble-across-the-NET-Application-Architecture-Guide.aspx#comment</comments>
      <guid>http://instantiate.co.nz/post.aspx?id=08ddf7f5-c4c4-4c98-9c98-5e177beea81c</guid>
      <pubDate>Mon, 28 Mar 2011 02:14:00 +2200</pubDate>
      <category>Blog</category>
      <dc:publisher>Luke</dc:publisher>
      <pingback:server>http://instantiate.co.nz/pingback.axd</pingback:server>
      <pingback:target>http://instantiate.co.nz/post.aspx?id=08ddf7f5-c4c4-4c98-9c98-5e177beea81c</pingback:target>
      <slash:comments>71</slash:comments>
      <trackback:ping>http://instantiate.co.nz/trackback.axd?id=08ddf7f5-c4c4-4c98-9c98-5e177beea81c</trackback:ping>
      <wfw:comment>http://instantiate.co.nz/post/I-get-fed-up-with-demoware-and-stumble-across-the-NET-Application-Architecture-Guide.aspx#comment</wfw:comment>
      <wfw:commentRss>http://instantiate.co.nz/syndication.axd?post=08ddf7f5-c4c4-4c98-9c98-5e177beea81c</wfw:commentRss>
    </item>
    <item>
      <title>Writing Entity Framework queries using LINQPad</title>
      <description>&lt;p&gt;I've been doing a bit of query tuning lately and have been introduced to &lt;a href="http://www.linqpad.net/"&gt;LINQPad&lt;/a&gt;&amp;nbsp;which makes writing and&amp;nbsp;tuning&amp;nbsp;LINQ queries easy.&lt;/p&gt;
&lt;p&gt;In this example I use the good old AdventureWorks database. I have an entity framework data access method that returns Customers for an email address&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Gets the customers with the given email address&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="emailAddress"&amp;gt;The email address.&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;A list of customers&amp;lt;/returns&amp;gt;&lt;br /&gt;public IList&amp;lt;Customer&amp;gt; GetCustomers(string emailAddress)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (var connection = new AdventureWorksLT2008Entities())&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return connection.Customer.Where(c =&amp;gt; c.EmailAddress == emailAddress).ToList();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;A fast way to figure out the sql that this query is executing is to fire up LINQPad and point it at the assembly with the Entity Framework data model (EDMX) file in it. If we add a connection, we can choose to add a typed data context from our own assembly&lt;/p&gt;
&lt;p&gt;&lt;img src="http://instantiate.co.nz/image.axd?picture=2011%2f3%2flinqpad1.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Once we point it at our assembly, LINQ pad detects that we have an EF data context and fills in the rest of the details from the default connection string used by the EDMX (in the assembly config file, which by default is copied to the output directory).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img src="http://instantiate.co.nz/image.axd?picture=2011%2f3%2flinqpad2.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;We now get a tree view of the various entity collections in our data context. We can copy our query into the query window, make a few tweaks like in-lining parameters with example values and execute our query against the database. LINQPad displays the results in a nice table view by default.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://instantiate.co.nz/image.axd?picture=2011%2f3%2flinqpad3.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;If we click on the SQL tab we can see the SQL that the EF engine has generated, from where we can copy it into SSMS or a similar tool to interrogate the execution plan and determine if&amp;nbsp;it will perform well. This also allows you to play around with different ways of writing LINQ queries to find the method that generates the best SQL while returning the data you need.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://instantiate.co.nz/image.axd?picture=2011%2f3%2flinqpad4.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;It's a bit of a trivial example but shows a real world approach to query development using Entity Framework. The ORM may abstract you from writing SQL but the way your queries are executed by the SQL engine is as important as ever!&lt;/p&gt;</description>
      <link>http://instantiate.co.nz/post/Performance-tuning-Entity-Framework-queries-using-LINQPad.aspx</link>
      <author>Luke</author>
      <comments>http://instantiate.co.nz/post/Performance-tuning-Entity-Framework-queries-using-LINQPad.aspx#comment</comments>
      <guid>http://instantiate.co.nz/post.aspx?id=19949269-9fd4-4450-a70e-43aa69756733</guid>
      <pubDate>Fri, 18 Mar 2011 02:32:00 +2200</pubDate>
      <category>Blog</category>
      <dc:publisher>Luke</dc:publisher>
      <pingback:server>http://instantiate.co.nz/pingback.axd</pingback:server>
      <pingback:target>http://instantiate.co.nz/post.aspx?id=19949269-9fd4-4450-a70e-43aa69756733</pingback:target>
      <slash:comments>203</slash:comments>
      <trackback:ping>http://instantiate.co.nz/trackback.axd?id=19949269-9fd4-4450-a70e-43aa69756733</trackback:ping>
      <wfw:comment>http://instantiate.co.nz/post/Performance-tuning-Entity-Framework-queries-using-LINQPad.aspx#comment</wfw:comment>
      <wfw:commentRss>http://instantiate.co.nz/syndication.axd?post=19949269-9fd4-4450-a70e-43aa69756733</wfw:commentRss>
    </item>
    <item>
      <title>Contract first vs Code first WCF</title>
      <description>&lt;p&gt;It's a bit of an aging debate but I thought I'd share my two cents regarding contract first WCF development seeing as I've been using it on a project for a while now.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Writing XSD markup is painful.&lt;/strong&gt;&lt;br /&gt;Put simply, it's my opinion that if you don't have to, don't do it! Sure, like anything once you get used to it you get fast at it. That doesn't mean you should be spending your time doing it, particularly when WCF can do it for you. Tools that validate and visualise xsd files for you as you write them help, like &lt;a href="http://www.altova.com/xml-editor/"&gt;Altova's XMLSpy&lt;/a&gt;. The ability to look at a tree representation of your contract graph as you write the XSD is really useful. Plus it's a great way to start off your documentation around consuming the services, if you're writing services for public consumption.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pretty XML schemas help people who consume your service.&lt;/strong&gt;&lt;br /&gt;Having a readable XSD with comments and annotation that is all contained in one file has got to be helpful for the developers consuming your service. It's pretty easy to use a WCF behaviour extension to serve up a static WSDL that links that XSD file you spent so long hand crafting. We published draft XSD files well ahead of implementation to give the consumers of our service an indication of the operations and types we were planning in the near future, contract first made this easier.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pretty XML schemas != pretty contract code&lt;/strong&gt;&lt;br /&gt;There is a tradeoff between clean XML schemas, and clean contract code. You need to constantly consider what is best in each situation. I recently had a situation where I had two operations that contained different elements with the same sequence of inner elements. It was tidier in the XSD to declare this as two different elements with different names, of the same type. The issue with this however was that in code I wanted two contract types as these objects needed to be treated differently. You can use composition, inheritance or repetition in the XSD to achieve this - none of which are optimal!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Would I do it again?&lt;/strong&gt;&lt;br /&gt;If I were publishing a public or externally consumed endpoint, yes. For services within an organisation or that are part of an application and not for external consumption? Nope!&lt;/p&gt;</description>
      <link>http://instantiate.co.nz/post/Contract-first-vs-Code-first-WCF.aspx</link>
      <author>Luke</author>
      <comments>http://instantiate.co.nz/post/Contract-first-vs-Code-first-WCF.aspx#comment</comments>
      <guid>http://instantiate.co.nz/post.aspx?id=bbd5e874-0c7f-49ed-8ccf-84470417c842</guid>
      <pubDate>Sat, 26 Feb 2011 08:24:00 +2200</pubDate>
      <category>Blog</category>
      <dc:publisher>Luke</dc:publisher>
      <pingback:server>http://instantiate.co.nz/pingback.axd</pingback:server>
      <pingback:target>http://instantiate.co.nz/post.aspx?id=bbd5e874-0c7f-49ed-8ccf-84470417c842</pingback:target>
      <slash:comments>600</slash:comments>
      <trackback:ping>http://instantiate.co.nz/trackback.axd?id=bbd5e874-0c7f-49ed-8ccf-84470417c842</trackback:ping>
      <wfw:comment>http://instantiate.co.nz/post/Contract-first-vs-Code-first-WCF.aspx#comment</wfw:comment>
      <wfw:commentRss>http://instantiate.co.nz/syndication.axd?post=bbd5e874-0c7f-49ed-8ccf-84470417c842</wfw:commentRss>
    </item>
    <item>
      <title>Using the Windows timezone for Enterprise Library logging formatters.</title>
      <description>&lt;p&gt;By  default entlib uses GMT time for timestamps. If you're in New Zealand  this means the timestamps  on your log entries are all incorrect.&amp;nbsp; This  is something that I always forget how to do but it is very  easy to correct. If you have a text formatter that looks similar to:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;formatters&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;  &amp;nbsp; &amp;lt;add template="Timestamp: {timestamp}&amp;amp;#xD;&amp;amp;#xA;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Message:  {message}&amp;amp;#xD;&amp;amp;#xA;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Category: {category}&amp;amp;#xD;&amp;amp;#xA;)}"&lt;br /&gt; &amp;nbsp;&amp;nbsp;  &amp;nbsp; type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter,  &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,  Culture=neutral, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PublicKeyToken=b03f5f7f11d50a3a" name="Text Formatter" /&amp;gt;&lt;br /&gt;&amp;lt;/formatters&amp;gt; &lt;/code&gt;&lt;/p&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;You  simply need to change the {timestamp} to&amp;nbsp;{timestamp&lt;strong&gt;(local)&lt;/strong&gt;} and it will  use the server timezone. Easy.&lt;/div&gt;</description>
      <link>http://instantiate.co.nz/post/Using-the-Windows-timezone-for-Enterprise-Library-logging-formatters.aspx</link>
      <author>Luke</author>
      <comments>http://instantiate.co.nz/post/Using-the-Windows-timezone-for-Enterprise-Library-logging-formatters.aspx#comment</comments>
      <guid>http://instantiate.co.nz/post.aspx?id=5197f813-b7f0-4994-92f1-35147a05c1a0</guid>
      <pubDate>Mon, 25 Oct 2010 23:36:00 +2200</pubDate>
      <category>Blog</category>
      <dc:publisher>Luke</dc:publisher>
      <pingback:server>http://instantiate.co.nz/pingback.axd</pingback:server>
      <pingback:target>http://instantiate.co.nz/post.aspx?id=5197f813-b7f0-4994-92f1-35147a05c1a0</pingback:target>
      <slash:comments>94</slash:comments>
      <trackback:ping>http://instantiate.co.nz/trackback.axd?id=5197f813-b7f0-4994-92f1-35147a05c1a0</trackback:ping>
      <wfw:comment>http://instantiate.co.nz/post/Using-the-Windows-timezone-for-Enterprise-Library-logging-formatters.aspx#comment</wfw:comment>
      <wfw:commentRss>http://instantiate.co.nz/syndication.axd?post=5197f813-b7f0-4994-92f1-35147a05c1a0</wfw:commentRss>
    </item>
    <item>
      <title>Regular expressions with MSBuild. Reading version numbers from AssemblyInfo.cs</title>
      <description>&lt;p&gt;I'm a huge fan of continuous integration and automated builds. I've written about &lt;a href="http://instantiate.co.nz/post/Automated-builds-and-deployments-with-TeamCity-and-MSBuild.aspx"&gt;MSBuild before&lt;/a&gt; and find myself using it a lot; mainly because it's familiar and build scripts aren't the sort of thing you have a lot of time to spend on.&amp;nbsp; I've used MSBuild to increment version numbers before, every build having a different number is a good idea (MSDN, 2010). Previously I have written the build number that gets incremented into a text file containing only the number, so it is nice and easy to fetch.&lt;/p&gt;
&lt;p&gt;Recently though I wanted to read the version (Major.Minor.Build.Revision) numbers from the assemblyInfo file into properties in my build script, so I could modify and use them as required. What follows is an MSBuild target that uses the &lt;a href="http://msbuildtasks.tigris.org/"&gt;MSBuild Community Tasks&lt;/a&gt; RegexMatch and RegexReplace tasks to do just that.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;ReadLinesFromFile File="$(VersionInfoFile)"&amp;gt;&lt;br /&gt; &amp;lt;Output TaskParameter="Lines" ItemName="IterationNumberFileContents"/&amp;gt;&lt;br /&gt;&amp;lt;/ReadLinesFromFile&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;First we read all the lines from the versionInfoFile into a task item. I have a file that contains just the solution version with the other solution info properties in another file. This will work if this is a full solution info file though.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;RegexMatch Input="@(IterationNumberFileContents)"  Expression="AssemblyVersion\(\"(\d+)\.(\d+)\.(\d+)\.(\d+)"&amp;gt;&lt;br /&gt;&amp;lt;Output ItemName="VersionNumberLineReturn"  TaskParameter="Output"/&amp;gt;&lt;br /&gt;&amp;lt;/RegexMatch&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Next we use the RegexMatch task to find the string &lt;em&gt;AssemblyVersion("X.X.X.X&lt;/em&gt; in the file (X's being any number). Note that we escape the parenthesis and quotes with a backslash as these have meaning in regular expressions. We wrap each digit selector in parenthesis (\d+) so that we can refer to it as a regular expression group. The .NET regular expression engine allows you to reference parts of the selection using back references (Goyvaerts, 2010). $0 represents the entire string matched (in our case &lt;em&gt;AssemblyVersion("X.X.X.X&lt;/em&gt; ). $1 - $9 represent groups in the order they were matched. In our case $1 throu&lt;em&gt;g&lt;/em&gt;h - $4 represent the four version numbers.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;RegexReplace Input="@(VersionNumberLineReturn)"  Expression="\[assembly\: (AssemblyVersion)\(\"(\d+)\.(\d+)\.(\d+)\.(\d+)\$(DOUBLE_QUOTES)\)\]"  Replacement="$1" Count="1"&amp;gt;&amp;lt;Output PropertyName="MajorNumber" TaskParameter="Output"/&amp;gt;&lt;br /&gt;&amp;lt;/RegexReplace&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;div&gt;This makes it easy to select out each version number into a property using these back references and the same regular expression. Above we are selecting the major version into the $(MajorVersion) property. I'm sure there is a more elegant way to do this than repeating the regular expression, but I don't know how to specify multiple outputs from the regexMatch/regexReplace tasks.&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;The full target which selects all four version numbers into properties is available to download &lt;a href="http://instantiate.co.nz/file.axd?file=2010%2f10%2fGetVersionNumberFromAssemblyInfoFile.msbuild.txt"&gt;here (2.00 kb)&lt;/a&gt;, I hope this saves you some time.&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;References:&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;Goyvaerts, Jan. (2010). &lt;em&gt;Replacement text reference.&lt;/em&gt; &lt;a href="http://www.regular-expressions.info/refreplace.html"&gt;http://www.regular-expressions.info/refreplace.html&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;MSDN. (2010). &lt;em&gt;Assembly Versioning.&lt;/em&gt; &lt;a href="http://msdn.microsoft.com/en-us/library/51ket42z%28v=VS.100%29.aspx"&gt;http://msdn.microsoft.com/en-us/library/51ket42z%28v=VS.100%29.aspx&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;</description>
      <link>http://instantiate.co.nz/post/Regular-expressions-with-MSBuild-Reading-version-numbers-from-AssemblyInfocs.aspx</link>
      <author>Luke</author>
      <comments>http://instantiate.co.nz/post/Regular-expressions-with-MSBuild-Reading-version-numbers-from-AssemblyInfocs.aspx#comment</comments>
      <guid>http://instantiate.co.nz/post.aspx?id=8b61edb0-f681-4e77-80a6-966d7de7b4c3</guid>
      <pubDate>Mon, 04 Oct 2010 01:40:00 +2200</pubDate>
      <category>Blog</category>
      <dc:publisher>Luke</dc:publisher>
      <pingback:server>http://instantiate.co.nz/pingback.axd</pingback:server>
      <pingback:target>http://instantiate.co.nz/post.aspx?id=8b61edb0-f681-4e77-80a6-966d7de7b4c3</pingback:target>
      <slash:comments>49</slash:comments>
      <trackback:ping>http://instantiate.co.nz/trackback.axd?id=8b61edb0-f681-4e77-80a6-966d7de7b4c3</trackback:ping>
      <wfw:comment>http://instantiate.co.nz/post/Regular-expressions-with-MSBuild-Reading-version-numbers-from-AssemblyInfocs.aspx#comment</wfw:comment>
      <wfw:commentRss>http://instantiate.co.nz/syndication.axd?post=8b61edb0-f681-4e77-80a6-966d7de7b4c3</wfw:commentRss>
    </item>
    <item>
      <title>The template method pattern: processing WCF requests</title>
      <description>&lt;p&gt;Im working on a project at the moment building a message bus using WCF.  We have a submit data method that takes a number of different message  types; create widget, update widget etc. We need to process these  requests quite differently based on the type of message passed  in but there is some commonality to the processing for all message  types.&lt;br /&gt; &lt;br /&gt; The template method pattern was really useful here, we have a base message  processor that contains the common processing steps and provides a  "hook" method that specific message processor sub classes can  override. This base class takes care of common logic for us like  storing the message payload for audit and saving any results from processing. The code looks  like this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;span&gt;public abstract MessageProcessorBase&amp;lt;TMessage&amp;gt; &lt;br /&gt;{&lt;/span&gt;&lt;br /&gt; &lt;span style="padding-left: 30px;"&gt;public void ProcessMessage(TMessage message)&lt;br /&gt;&lt;/span&gt; &lt;span style="padding-left: 30px;"&gt;{&lt;br /&gt;&lt;/span&gt; &lt;span style="padding-left: 60px;"&gt;StoreMessage(message);&lt;/span&gt;&lt;span style="padding-left: 60px;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span style="padding-left: 60px;"&gt;ProcessingResults results = ProcessMessageByType();&lt;br /&gt;&lt;/span&gt; &lt;span style="padding-left: 60px;"&gt;SaveProcessingResults(results);&lt;br /&gt;&lt;/span&gt; &lt;span style="padding-left: 30px;"&gt;}&lt;br /&gt;&lt;/span&gt; &lt;br /&gt; &lt;span style="padding-left: 30px;"&gt;protected abstract ProcessingResults ProcessMessageByType();&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="padding-left: 30px;"&gt;private void StoreMessage(TMessage)&lt;/span&gt;&lt;br /&gt;&lt;span style="padding-left: 30px;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="padding-left: 60px;"&gt;...&lt;/span&gt;&lt;br /&gt;&lt;span style="padding-left: 30px;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="padding-left: 30px;"&gt;private void SaveProcessingResults(ProcessingResults results)&lt;/span&gt;&lt;br /&gt;&lt;span style="padding-left: 30px;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="padding-left: 60px;"&gt;...&lt;/span&gt;&lt;br /&gt;&lt;span style="padding-left: 30px;"&gt;}&lt;/span&gt;&lt;br /&gt;}&lt;/code&gt;&lt;/p&gt;
&lt;div&gt;All of these methods are private on the &amp;nbsp;MessageProcessorBase except the  ProceessMessageByType which is abstract and overridden in the subtypes.  Now for each message type we simply create a message processor and  implement the specific processing logic.&lt;/div&gt;
&lt;p&gt;&lt;img src="http://instantiate.co.nz/image.axd?picture=2010%2f9%2ftemplateImageMessageProcessors1.jpg" alt="Template message processors class diagram" /&gt;&lt;/p&gt;
&lt;div&gt;The message processor base is generic meaning it can be strongly typed to each specific message type, while not being tied to any one message type. The nice thing about this is that we have a strongly typed message processor for each message type.&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;That's all there is to it, a tidy way of using inheritence to make our message processor class closed to change but open to extension. &lt;br /&gt;&lt;/div&gt;</description>
      <link>http://instantiate.co.nz/post/The-template-method-pattern-processing-WCF-requests.aspx</link>
      <author>Luke</author>
      <comments>http://instantiate.co.nz/post/The-template-method-pattern-processing-WCF-requests.aspx#comment</comments>
      <guid>http://instantiate.co.nz/post.aspx?id=9f5fe696-7e88-48f0-87c6-9cbae90c31b4</guid>
      <pubDate>Thu, 23 Sep 2010 06:57:00 +2200</pubDate>
      <category>Blog</category>
      <dc:publisher>Luke</dc:publisher>
      <pingback:server>http://instantiate.co.nz/pingback.axd</pingback:server>
      <pingback:target>http://instantiate.co.nz/post.aspx?id=9f5fe696-7e88-48f0-87c6-9cbae90c31b4</pingback:target>
      <slash:comments>84</slash:comments>
      <trackback:ping>http://instantiate.co.nz/trackback.axd?id=9f5fe696-7e88-48f0-87c6-9cbae90c31b4</trackback:ping>
      <wfw:comment>http://instantiate.co.nz/post/The-template-method-pattern-processing-WCF-requests.aspx#comment</wfw:comment>
      <wfw:commentRss>http://instantiate.co.nz/syndication.axd?post=9f5fe696-7e88-48f0-87c6-9cbae90c31b4</wfw:commentRss>
    </item>
    <item>
      <title>AUT University What I Wanna Be Video</title>
      <description>&lt;p&gt;I was recently asked to feature in an AUT University television promo on MTV New Zealand.&amp;nbsp; 'What I Wanna Be' is a series of short videos each featuring an AUT graduate and focusing on what they are doing now.&amp;nbsp; I was honoured to be selected to appear in the video.&amp;nbsp; It has been airing on MTV for a week or so but is attached below if you'd like to watch it.&lt;/p&gt;
&lt;p&gt;
&lt;object width="480" height="385"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/JbCTKUK_7x4?fs=1&amp;amp;hl=en_US" /&gt;
&lt;param name="allowFullScreen" value="true" /&gt;
&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/JbCTKUK_7x4?fs=1&amp;amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;
&lt;/object&gt;
&lt;/p&gt;
&lt;p&gt;The video was a lot of fun to make, the MTV crew were awesome.&amp;nbsp; You can win a Macbook by answering a few questions about it on the &lt;a href="http://www.mtv.co.nz/win/mtvnz_aut_what_i_wanna_be/"&gt;MTV website&lt;/a&gt;.&lt;/p&gt;</description>
      <link>http://instantiate.co.nz/post/AUT-University-What-I-Wanna-Be-Promo.aspx</link>
      <author>Luke</author>
      <comments>http://instantiate.co.nz/post/AUT-University-What-I-Wanna-Be-Promo.aspx#comment</comments>
      <guid>http://instantiate.co.nz/post.aspx?id=8c6dd888-7fa0-4d8d-8af7-10a8a5ed3699</guid>
      <pubDate>Sun, 05 Sep 2010 23:38:00 +2200</pubDate>
      <category>Blog</category>
      <dc:publisher>Luke</dc:publisher>
      <pingback:server>http://instantiate.co.nz/pingback.axd</pingback:server>
      <pingback:target>http://instantiate.co.nz/post.aspx?id=8c6dd888-7fa0-4d8d-8af7-10a8a5ed3699</pingback:target>
      <slash:comments>37</slash:comments>
      <trackback:ping>http://instantiate.co.nz/trackback.axd?id=8c6dd888-7fa0-4d8d-8af7-10a8a5ed3699</trackback:ping>
      <wfw:comment>http://instantiate.co.nz/post/AUT-University-What-I-Wanna-Be-Promo.aspx#comment</wfw:comment>
      <wfw:commentRss>http://instantiate.co.nz/syndication.axd?post=8c6dd888-7fa0-4d8d-8af7-10a8a5ed3699</wfw:commentRss>
    </item>
  </channel>
</rss>