<?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/"
	>

<channel>
	<title>Progressive Digressive &#187; .net</title>
	<atom:link href="http://www.marcuswhitworth.com/tag/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marcuswhitworth.com</link>
	<description>Marcus Whitworth&#039;s tech blog – .NET, C#, Silverlight, WPF, Flex…etc, etc</description>
	<lastBuildDate>Wed, 14 Dec 2011 16:14:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>iTunes to Zune playlist converter app for Windows Phone 7</title>
		<link>http://www.marcuswhitworth.com/2011/11/itunes-to-zune-playlist-converter-app-for-windows-phone-7-use/</link>
		<comments>http://www.marcuswhitworth.com/2011/11/itunes-to-zune-playlist-converter-app-for-windows-phone-7-use/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 22:18:07 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[wp7]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=212</guid>
		<description><![CDATA[I moved from an iPhone to a WP7 device recently, and one of niggles in the move was getting my iTunes playlists imported into Zune.  Doesn&#8217;t seem like there&#8217;s a simple way to accomplish this, so I created a small &#8230; <a href="http://www.marcuswhitworth.com/2011/11/itunes-to-zune-playlist-converter-app-for-windows-phone-7-use/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I moved from an iPhone to a WP7 device recently, and one of niggles in the move was getting my iTunes playlists imported into Zune.  Doesn&#8217;t seem like there&#8217;s a simple way to accomplish this, so I created a small windows app to do it for me.</p>
<p>You can download it below.  Just run it (you&#8217;ll need .NET 4 framework installed), and it should detect your iTunes playlists automatically.  It won&#8217;t import m4p files in your playlists, as they&#8217;re DRM protected and can only be played via iTunes.</p>
<p><img src="http://www.marcuswhitworth.com/wp-content/uploads/2011/11/ITunesToZunePlaylistConverter-Running-Microsoft-Visual-Studio-Administrator_2011-11-27_22-22-41.png" alt="" width="600" /></p>
<p>You can <a href="https://skydrive.live.com/redir.aspx?cid=2766a525cd9fa8ec&#038;resid=2766A525CD9FA8EC!223" target="_blank">download the application for your own use here</a>.</p>
<div class="shr-publisher-212"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2011%2F11%2Fitunes-to-zune-playlist-converter-app-for-windows-phone-7-use%2F' data-shr_title='iTunes+to+Zune+playlist+converter+app+for+Windows+Phone+7'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2011%2F11%2Fitunes-to-zune-playlist-converter-app-for-windows-phone-7-use%2F' data-shr_title='iTunes+to+Zune+playlist+converter+app+for+Windows+Phone+7'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2011/11/itunes-to-zune-playlist-converter-app-for-windows-phone-7-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rx &#8211; System Time and Scheduler issues</title>
		<link>http://www.marcuswhitworth.com/2011/09/rx-system-time-and-scheduler-issues/</link>
		<comments>http://www.marcuswhitworth.com/2011/09/rx-system-time-and-scheduler-issues/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 16:36:06 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[rx]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=188</guid>
		<description><![CDATA[I recently had an issue with time-dependent methods of Rx, which were adversely affected when a user changed their system clock.  You can read up on the history on the Rx forums. In the older Rx v1.0.2787 (which my current &#8230; <a href="http://www.marcuswhitworth.com/2011/09/rx-system-time-and-scheduler-issues/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I recently had an issue with time-dependent methods of Rx, which were adversely affected when a user changed their system clock.  You can read up on the history <a href="http://social.msdn.microsoft.com/Forums/en/rx/thread/672a9b1d-c25e-4797-ad24-5f3252089df0" target="_blank">on the Rx forums</a>.</p>
<p>In the older Rx v1.0.2787 (which my current project is still using), <em>BufferWithTime</em> was affected, along with other methods such as <em>Interval, Timer, </em>and<em> Sample. </em></p>
<p>The most problematic for my purposes was <em>BufferWithTime</em><em>. </em> For instance, if you shift the system clock back and then push values onto the Buffer, the values are then either lost completely or they arrive late.  If you shift the clock forward a significant amount, Rx overloads the CPU pushing through potentially thousands of empty updates in an effort to catch up with the new clock time.  Worse still, if you shift your clock back several years then you get an UnhandledException along the lines of &#8220;Time-out interval must be less than 2^32-2&#8243;.</p>
<p>In the latest Rx v1.1.10621 (experimental), it seems neither <em>Buffer </em>nor <em>Window</em> are affected, but <em>Interval, Timer, </em>and<em> Sample</em> are.</p>
<p>In short, the issue is that all problematic methods are dependent upon <em>IScheduler.Now</em>.  In all <em>IScheduler</em> implementations, this property just returns <em>DateTimeOffset.Now</em>, which is of course straight from the system clock.  Change the system clock, and subsequent reads of <em>IScheduler.Now</em> will return times not in line with previous values.</p>
<p>The solution was to implement a custom <em>IScheduler</em>.  I&#8217;ve quite literally copied the <em>ThreadPoolScheduler</em> source, and simply modified the <em>Now</em> property implementation.</p>
<p>In my implementation below, you can see that I start a <em>Stopwatch</em> during construction, and use this to determine the actual time in the getter for <em>Now</em>.  From my testing it behaves correctly in all situations where I was previously missing notifications.  The relevant parts are the constructor and the <em>Now</em> getter, all other methods are simply a copy of the <em>ThreadPoolScheduler</em>.</p>
<p><a href="http://www.marcuswhitworth.com/wp-content/uploads/2011/09/RxTimerTests.zip">Attached here</a> is a sample project demonstrating both the issue and the fix for the latest Rx release.  Just run it and hit the &#8220;-10 secs&#8221; button to shift your system clock back.</p>
<p>Thoughts and comments welcome&#8230;</p>
<pre class="brush:csharp">public class AccurateTimeScheduler : IScheduler, IDisposable
{
	private static readonly object _gate = new object();
	private static readonly Dictionary&lt;Timer, object&gt; _timers 
		= new Dictionary&lt;Timer, object&gt;();

	private readonly Stopwatch _stopWatch = new Stopwatch();
	private DateTimeOffset _startTime;

	public AccurateTimeScheduler()
	{
		_startTime = DateTimeOffset.Now;
		_stopWatch.Start();
	}

	public DateTimeOffset Now
	{
		get
		{
			var dateTimeOffset = _startTime.AddMilliseconds(
				_stopWatch.ElapsedMilliseconds);

			Trace.WriteLine(
				string.Format("Now: Default={0}, Corrected={1}",
					            DateTimeOffset.Now.ToString("HH:mm:ss.fff"),
					            dateTimeOffset.ToString("HH:mm:ss.fff")));
			return _startTime.AddMilliseconds(_stopWatch.ElapsedMilliseconds);
		}
	}

	public IDisposable Schedule&lt;TState&gt;(TState state, Func&lt;IScheduler, TState, IDisposable&gt; action)
	{
		if (action == null)
			throw new ArgumentNullException("action");
		var d = new SingleAssignmentDisposable();
		ThreadPool.QueueUserWorkItem(
			_ =&gt;
				{
					if (d.IsDisposed)
						return;
					d.Disposable = action((IScheduler) this, state);
				}, null);
		return d;
	}

	public IDisposable Schedule&lt;TState&gt;(TState state, TimeSpan dueTime, Func&lt;IScheduler, TState, IDisposable&gt; action)
	{
		if (action == null)
			throw new ArgumentNullException("action");
		var dueTime1 = Scheduler.Normalize(dueTime);
		if (dueTime1.Ticks == 0L)
			return Schedule(state, action);
		var hasAdded = false;
		var hasRemoved = false;
		var d = new MultipleAssignmentDisposable();
		Timer timer = null;
		timer = new Timer(
			_ =&gt;
				{
					Func&lt;IScheduler, TState, IDisposable&gt; localAction;
					lock (_gate)
					{
						if (hasAdded &amp;&amp; timer != null)
							_timers.Remove(timer);
						localAction = action;
					}
					var localTimer = timer;
					if (localTimer != null)
						localTimer.Dispose();
					timer = null;
					if (localAction != null)
					{
						d.Disposable = localAction((IScheduler) this, state);
						Trace.WriteLine("Executing");
					}
					action = null;
				}, null, dueTime1, TimeSpan.FromMilliseconds(-1.0));

		lock (_gate)
		{
			if (!hasRemoved)
			{
				_timers.Add(timer, null);
				hasAdded = true;
			}
		}

		d.Disposable = Disposable.Create(
			() =&gt;
				{
					var localTimer = timer;
					if (localTimer != null)
					{
						localTimer.Dispose();
						lock (_gate)
						{
							_timers.Remove(localTimer);
							action = null;
						}
					}
					timer = null;
				});
		return d;
	}

	public IDisposable Schedule&lt;TState&gt;(
TState state, DateTimeOffset dueTime, Func&lt;IScheduler, TState, IDisposable&gt; action)
	{
		if (action == null)
			throw new ArgumentNullException("action");

		return Schedule(state, dueTime - Now, action);
	}

	public void Dispose()
	{
		_stopWatch.Stop();
	}
}</pre>
<div class="shr-publisher-188"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2011%2F09%2Frx-system-time-and-scheduler-issues%2F' data-shr_title='Rx+-+System+Time+and+Scheduler+issues'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2011%2F09%2Frx-system-time-and-scheduler-issues%2F' data-shr_title='Rx+-+System+Time+and+Scheduler+issues'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2011/09/rx-system-time-and-scheduler-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Avoiding memory leaks with easier disposal</title>
		<link>http://www.marcuswhitworth.com/2010/12/avoiding-memory-leaks-with-easier-disposal/</link>
		<comments>http://www.marcuswhitworth.com/2010/12/avoiding-memory-leaks-with-easier-disposal/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 11:48:07 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[rx]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=165</guid>
		<description><![CDATA[One of the biggest causes of memory leaks in .NET applications (or any application), are event handlers remaining active beyond the lifetime of the parent object.  Your object goes out of scope, but continues to listen for events on other &#8230; <a href="http://www.marcuswhitworth.com/2010/12/avoiding-memory-leaks-with-easier-disposal/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>One of the biggest causes of memory leaks in .NET applications (or any application), are event handlers remaining active beyond the lifetime of the parent object.  Your object goes out of scope, but continues to listen for events on other objects, and hence can&#8217;t be garbage collected.  Typically, your class would implement <em>IDisposable</em>, and you&#8217;d remove all your event handlers in that method.  This works fine &#8211; if you keep track of all event handlers and remember to add the corresponding handler removal into your <em>Dispose</em> method.</p>
<p>Two more recent .NET developments which make this process easier to manage are the <em>CompositeDisposable</em> class, and of course <em>IObservable</em>, both of which can be found in the <a href="http://msdn.microsoft.com/en-us/devlabs/ee794896.aspx" target="_blank">Reactive Extensions (Rx)</a> assemblies.</p>
<p><em>CompositeDisposable</em> is simple &#8211; it&#8217;s just a collection of <em>IDisposable</em> objects.  When you call <em>Dispose</em> on your <em>CompositeDisposable</em>, all the items in the collection are disposed.  If you create a BaseDisposable class to be used a base for all your business classes, then you can have something like the following:</p>
<pre class="brush:csharp">public abstract class BaseDisposable : IDisposable
{
	protected CompositeDisposable Disposables = new CompositeDisposable();

	public bool IsDisposed { get; private set; }

	public virtual void Dispose()
	{
		using (Disposables)
		{
			Disposables = null;
		}
		IsDisposed = true;
	}
}

public class MyViewModel : BaseDisposable
{
	public MyViewModel()
	{
		var timer = Observable.Interval(TimeSpan.FromSeconds(1))
			.Subscribe(OnTimerCallback);
		Disposables.Add(timer);
	}

	private void OnTimerCallback(long count)
	{
		Trace.WriteLine(count.ToString());
	}
}</pre>
<p>In the above sample, the <em>MyViewModel</em> class inherits <em>BaseDisposable</em>, so when it is disposed, anything that has been added to the Disposables collection during it&#8217;s lifetime will also be disposed &#8211; no need to add a new Dispose method with lots of event handler removals.  I&#8217;ve just used a simple <em>IObservable</em> subscription in this example, and I haven&#8217;t implemented the Dispose pattern on my <em>BaseDisposable</em> &#8211; which would be a good idea in a real world scenario.  In <em>BaseDisposable</em>, there&#8217;s also an <em>IsDisposed</em> property available &#8211; this can be useful for unit tests to confirm whether your object has been disposed as expected.</p>
<p>It&#8217;s not anything ground breaking, but it will mean you don&#8217;t have to add a Dispose method to each of your classes with lots of handler removals and disposing of child disposables.  In short, cleaner and more maintainable.</p>
<p><em>IObservables</em> work particularly well with this pattern, as each Rx subscription implements <em>IDisposable</em>.  Concurrency, composition, and declarative syntax aside, this alone is a compelling reason to consider using Rx in place of regular event handlers in your application.  Rather than specifying the handler removal in your Dispose method, just add your subscription to the Disposables collection, and the handler will be removed when your object is disposed.</p>
<div class="shr-publisher-165"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2010%2F12%2Favoiding-memory-leaks-with-easier-disposal%2F' data-shr_title='Avoiding+memory+leaks+with+easier+disposal'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2010%2F12%2Favoiding-memory-leaks-with-easier-disposal%2F' data-shr_title='Avoiding+memory+leaks+with+easier+disposal'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2010/12/avoiding-memory-leaks-with-easier-disposal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic Linq with Expression Trees</title>
		<link>http://www.marcuswhitworth.com/2009/12/dynamic-linq-with-expression-trees/</link>
		<comments>http://www.marcuswhitworth.com/2009/12/dynamic-linq-with-expression-trees/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 19:28:16 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[expression trees]]></category>
		<category><![CDATA[linq]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=106</guid>
		<description><![CDATA[I recently came across a project requirement for the client to create custom validation rules for retrieving data from the SQL database. The rules needed be applied against any number of member applications, and can be altered by the client &#8230; <a href="http://www.marcuswhitworth.com/2009/12/dynamic-linq-with-expression-trees/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I recently came across a project requirement for the client to create custom validation rules for retrieving data from the SQL database.  The rules needed be applied against any number of member applications, and can be altered by the client at any point.</p>
<p>From the client perspective, the administration of the rules would look something like the following:</p>
<p><img class="aligncenter size-full wp-image-110" title="Rules Administration" src="http://www.marcuswhitworth.com/wp-content/uploads/2009/12/Screen-shot-2009-12-02-at-15.19.47.png" alt="Rules Administration" width="477" height="125" /></p>
<p>Simple enough concept.  Historically, given such a requirement, you&#8217;d likely end up with some fudged SQL string (if querying a database), and/or a whole lot of conditional logic.  The application already uses Linq2SQL, so I didn&#8217;t want to go backwards by introducing some extensive SQL string generation.</p>
<p>The first Linq based option I came across was the <a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx" target="_blank">Dynamic Linq Query Library</a>, which essentially enables you to use SQL-like strings as expressions in your conditional clauses.  Nice, but it still smelled a bit like the SQL string concatenation of old.</p>
<p>The second option I looked at was <a href="http://www.albahari.com/nutshell/predicatebuilder.aspx" target="_blank">PredicateBuilder</a>.  It&#8217;s a neat solution for the right problem, but it assumes that you know the properties/columns you&#8217;re querying against at compile time.</p>
<p>So, I decided to have a play around with Expression Trees, in an effort to dynamically generate my conditional expressions at runtime.  I hadn&#8217;t really delved much into this area before, so I figured it&#8217;d be a good learning experience, even if it didn&#8217;t end up working out.  To cut to the chase, the method I ended up with for parsing my rules into Lambda Expressions looks like the following:</p>
<pre  class="brush:csharp">public static Expression&lt;Func&lt;T, bool&gt;&gt; GetExpression&lt;T&gt;(
	string propertyName, string operatorType, string propertyValue)
{
	var isNegated = operatorType.StartsWith("!");
	if (isNegated)
		operatorType = operatorType.Substring(1);

	var parameter = Expression.Parameter(typeof (T), "type");
	var property = Expression.Property(parameter, propertyName);

	// Cast propertyValue to correct property type
	var td = TypeDescriptor.GetConverter(property.Type);
	var constantValue = Expression.Constant(td.ConvertFromString(propertyValue), property.Type);

	// Check if specified method is an Expression member
	var operatorMethod = typeof(Expression).GetMethod(operatorType, new[] { typeof(MemberExpression), typeof(ConstantExpression) });

	Expression expression;

	if (operatorMethod == null)
	{
		// Execute against type members
		var method = property.Type.GetMethod(operatorType, new[] {property.Type});
		expression = Expression.Call(property, method, constantValue);
	}
	else
	{
		// Execute the passed operator method (e.g. Expression.GreaterThan)
		expression = (Expression) operatorMethod.Invoke(null, new object[] {property, constantValue});
	}

	if (isNegated)
		expression = Expression.Not(expression);

	return Expression.Lambda&lt;Func&lt;T, bool&gt;&gt;(expression, parameter);
}</pre>
<p>Which can be executed with a call like the following:</p>
<pre class="brush:csharp">foreach (var rule in rules)
{
	applicants = applicants.Where(
		GetExpression&lt;Applicant&gt;(
			rule.MemberName, // The Applicant property
			rule.Operator, // Equals, Contains, GreaterThan, etc
			rule.Value)
		);
}</pre>
<p>The rules are looped over, and Linq does its magic by combining all the separate rules with AND statements in the resulting query.</p>
<p>A few things to note:</p>
<ul>
<li>Operators are just the method names to be called, against the Expression type, or any other CLR or custom type.  If you put a ! in front of the operator, it negates the method result (!Contains would read &#8216;Does Not Contain&#8217;).</li>
<li>Reflection isn&#8217;t necessary for building an expression, I just use it here to enable runtime operator implementation, against both the Expression class and potentially any other class.</li>
<li>If you wanted to combine your rules with OR statements, it could be done easily enough with logic similar to what PredicateBuilder uses.</li>
<li>There is possibly/probably better ways to do this &#8211; if you know one, speak up!</li>
</ul>
<p>Is this necessarily any better than using the Dynamic Linq library?  A bit &#8211; it doesn&#8217;t really give me any compile-time type safety benefits, but I could potentially handle certain exceptions that I perhaps wouldn&#8217;t be able to detect using Dynamic Linq, such as casting the value to the correct type.  On top of that, I like it more, it <em>feels</em> more robust, and doesn&#8217;t require external libraries to work.  If nothing else, it gave me an excuse to get my head around some lower-level Expression Tree stuff :)</p>
<div class="shr-publisher-106"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F12%2Fdynamic-linq-with-expression-trees%2F' data-shr_title='Dynamic+Linq+with+Expression+Trees'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F12%2Fdynamic-linq-with-expression-trees%2F' data-shr_title='Dynamic+Linq+with+Expression+Trees'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2009/12/dynamic-linq-with-expression-trees/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>ReSharper 5 &#8211; and I thought 4 was good</title>
		<link>http://www.marcuswhitworth.com/2009/10/resharper-5-and-i-thought-4-was-good/</link>
		<comments>http://www.marcuswhitworth.com/2009/10/resharper-5-and-i-thought-4-was-good/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 12:12:27 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=91</guid>
		<description><![CDATA[Reading this preliminary list of the upcoming features of ReSharper 5, it makes me wonder how any .NET developer could ever be without a tool like this.  Among the favorites would have to be Project Refactorings, and Call/Value Tracking.  Genius. &#8230; <a href="http://www.marcuswhitworth.com/2009/10/resharper-5-and-i-thought-4-was-good/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Reading <a href="http://blogs.jetbrains.com/dotnet/2009/10/resharper-50-overview/" target="_blank">this preliminary list of the upcoming features</a> of ReSharper 5, it makes me wonder how any .NET developer could ever be without a tool like this.  Among the favorites would have to be Project Refactorings, and Call/Value Tracking.  Genius.</p>
<p>Having used the refactoring-and-<em>[insert feature here]</em>-anaemic <a href="http://www.adobe.com/products/flex/features/flex_builder/" target="_blank">Flex Builder 3</a> at length on a few recent projects, life just seems to get better and better in Visual Studio land.</p>
<div class="shr-publisher-91"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F10%2Fresharper-5-and-i-thought-4-was-good%2F' data-shr_title='ReSharper+5+-+and+I+thought+4+was+good'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F10%2Fresharper-5-and-i-thought-4-was-good%2F' data-shr_title='ReSharper+5+-+and+I+thought+4+was+good'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2009/10/resharper-5-and-i-thought-4-was-good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a custom Silverlight 3 Smooth Streaming player</title>
		<link>http://www.marcuswhitworth.com/2009/09/creating-a-custom-silverlight-3-smooth-streaming-player/</link>
		<comments>http://www.marcuswhitworth.com/2009/09/creating-a-custom-silverlight-3-smooth-streaming-player/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 18:36:39 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=64</guid>
		<description><![CDATA[When it comes to video delivery, I come from a Flash background.  I&#8217;ve worked on numerous streaming video projects over the years, all of which were created with Flash &#38; Actionscript on the client side. Having been through the process &#8230; <a href="http://www.marcuswhitworth.com/2009/09/creating-a-custom-silverlight-3-smooth-streaming-player/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>When it comes to video delivery, I come from a Flash background.  I&#8217;ve worked on numerous streaming video projects over the years, all of which were created with Flash &amp; Actionscript on the client side. Having been through the process several times, I know all the hurdles I&#8217;m going to have to clear well in advance.</p>
<p>Documentation for coding a Silverlight 3 player against IIS Smooth Streaming is a little sparse.  IIS.net has several articles on the server setup, but I couldn&#8217;t find anywhere obvious regarding the client connection.</p>
<p>Unlike progressive video playback, you can&#8217;t just point the MediaElement.source at the video path then call play().  After a bit of searching, <a href="http://chris.59north.com/post/Playing-Smooth-Streaming-videos-in-Silverlight.aspx" target="_blank">most people were talking about</a> some <em>AdaptiveStreamingSource</em> class, which isn&#8217;t available in the base SL toolkit, but rather only found in <em>SmoothStreaming.dll</em> within the template players generated from Expression Encoder!</p>
<p>Per <a href="http://forums.silverlight.net/forums/t/121952.aspx" target="_blank">some handy forum posts</a>, the steps required are:</p>
<ol>
<li>With Expression Encoder installed, go to <em>C:\Program Files\Microsoft Expression\Encoder 3\Templates\en</em>, select any template, and copy the SmoothStreaming.xap file.</li>
<li>Rename your copied .xap file to .zip, unzip, and take out the <em>SmoothStreaming.dll</em> and <em>PlugInMssCtrl.dll</em> files.</li>
<li>Reference these assemblies in your project, and you can then start using <em>AdaptiveStreamingSource.</em></li>
</ol>
<p>So, once you can finally access the required assemblies, you can then invoke your IIS Smooth Streaming service with something along the lines of the following:</p>
<pre class="brush:csharp">var mediaPath = "testClip_h1080p.ism/manifest";
var source = new AdaptiveStreamingSource
{
   ManifestUrl = new Uri(mediaPath, UriKind.RelativeOrAbsolute),
   MediaElement = streamElement // the xaml MediaElement
};
source.StartPlayback();</pre>
<p>Make sure you put the trailing &#8216;/manifest&#8217; after your stream path.</p>
<p>Simple enough, once you&#8217;ve figured out the basics!  Not exactly sure what MS were thinking by not including the SmoothStreaming assemblies in the SL3 toolkit?  Surely they realise not everyone wants to use a templated player.  Or have I missed something here?</p>
<div class="shr-publisher-64"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F09%2Fcreating-a-custom-silverlight-3-smooth-streaming-player%2F' data-shr_title='Creating+a+custom+Silverlight+3+Smooth+Streaming+player'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F09%2Fcreating-a-custom-silverlight-3-smooth-streaming-player%2F' data-shr_title='Creating+a+custom+Silverlight+3+Smooth+Streaming+player'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2009/09/creating-a-custom-silverlight-3-smooth-streaming-player/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio Silverlight/xaml bug</title>
		<link>http://www.marcuswhitworth.com/2009/09/visual-studio-silverlight-xaml-bug/</link>
		<comments>http://www.marcuswhitworth.com/2009/09/visual-studio-silverlight-xaml-bug/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 17:45:42 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Bugs]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=60</guid>
		<description><![CDATA[This one was driving me crazy for at least a few hours.  On a fresh install of VS2008 &#38; Silverlight 3 tools, there was no xaml code highlighting at all, no intellisense, nothing &#8211; just like any ordinary text file.  &#8230; <a href="http://www.marcuswhitworth.com/2009/09/visual-studio-silverlight-xaml-bug/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>This one was driving me crazy for at least a few hours.  On a fresh install of VS2008 &amp; Silverlight 3 tools, there was no xaml code highlighting at all, no intellisense, nothing &#8211; just like any ordinary text file.  Checking the same project on another machine, it was all fine.  So I starting disabling/uninstalling all VS plugins (ReSharper, AnkhSVN), but still no luck.  Was starting to think I&#8217;d have to reinstall VS&#8230;</p>
<p><a href="http://www.tipsdotnet.com/TechBlog.aspx?PageIndex=0&amp;BLID=12" target="_blank">The solution</a> was simple enough &#8211; run the VS Command Prompt, and enter:</p>
<pre>devenv /resetskippkgs</pre>
<p>Problem solved.  <a href="http://msdn.microsoft.com/en-us/library/ms241276%28VS.80%29.aspx" target="_blank">Apparently a good one to try</a> whenever you lose formatting or Intellisense features.</p>
<div class="shr-publisher-60"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F09%2Fvisual-studio-silverlight-xaml-bug%2F' data-shr_title='Visual+Studio+Silverlight%2Fxaml+bug'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F09%2Fvisual-studio-silverlight-xaml-bug%2F' data-shr_title='Visual+Studio+Silverlight%2Fxaml+bug'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2009/09/visual-studio-silverlight-xaml-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET Development on a Mac &#8211; Fusion or Parallels?</title>
		<link>http://www.marcuswhitworth.com/2009/09/dotnet-development-on-a-mac-fusion-or-parallels/</link>
		<comments>http://www.marcuswhitworth.com/2009/09/dotnet-development-on-a-mac-fusion-or-parallels/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 22:00:40 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Comparisons]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.marcuswhitworth.com/?p=34</guid>
		<description><![CDATA[I&#8217;ve been recently issued with my first Mac for work, and have been in the process of setting it up as my dev machine.  I&#8217;m familiar with using Mac&#8217;s in several roles over the years, but resisted using one day-to-day &#8230; <a href="http://www.marcuswhitworth.com/2009/09/dotnet-development-on-a-mac-fusion-or-parallels/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I&#8217;ve been recently issued with my first Mac for work, and have been in the process of setting it up as my dev machine.  I&#8217;m familiar with using Mac&#8217;s in several roles over the years, but resisted using one day-to-day until now.  I&#8217;ve got the <a href="http://www.apple.com/uk/macbookpro/specs-13inch.html" target="_blank">base level Macbook Pro</a> (2.26mhz, upgraded to 4gb ram).</p>
<p>Among other apps, I need to run Visual Studio 2008 and SQL Server 2008.  Using <a href="http://www.apple.com/support/bootcamp/" target="_blank">Bootcamp</a> crossed my mind, but I didn&#8217;t like the the idea of rebooting into Windows every time I wanted to look at something dev-related.</p>
<p>So, I downloaded the trial of <a href="http://www.vmware.com/products/fusion/" target="_blank">VMWare Fusion 2.05</a>, installed a shiny new copy of Windows 7 Pro, installed VS2008 Pro, SQL2008, ReSharper, etc, and prepared to be amazed by my new efficient setup.</p>
<p>In short, it was pretty painful &#8211; everything just seemed to lag.  I was expecting it to be a bit slower than running natively, but after 20 minutes I realised it just wasn&#8217;t going to work.  I googled to see if this was a common experience, and came across this fairly comprehensive <a href="http://www.mactech.com/articles/mactech/Vol.25/25.04/VMBenchmarks/index.html" target="_blank">comparison between Fusion and Parallels</a> which concludes &#8220;Parallels Desktop is the clear winner running 14-20% faster than VMware Fusion&#8221;.  That&#8217;s an impressive difference on any benchmark!</p>
<p>One very nice feature of both Fusion and Parallels is that you can import the competitor&#8217;s virtual image into the other.  So after reading this comparison, I figured I had nothing to lose &#8211; the next option was to just set up in Bootcamp which still wasn&#8217;t appealing.  I downloaded and installed <a href="http://www.parallels.com/products/desktop/" target="_blank">Parallels 4</a>, imported my Fusion virtual image, and 20 mins later I booted up the new Parallels image.</p>
<p>This was exactly what I was hoping for &#8211; the experience was <span style="text-decoration: underline;">vastly</span> superior.  No obvious lag when opening/closing programs, responsive, didn&#8217;t slow down my other Mac programs at all, and just slicker.  Build times of existing VS projects may be a bit slower than running natively (understandable given only one cpu core is allocated to the virtual OS &#8211; I think), but overall it feels pretty snappy, and definitely not slow to the point I&#8217;d bother rebooting into Bootcamp.  It&#8217;s worth pointing out that I allocated 2gb memory (of 4gb total) to running each Fusion and Parallels &#8211; so they were on a fairly level playing field.</p>
<p>Parallels: 1 &#8211; Fusion: 0</p>
<div class="shr-publisher-34"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F09%2Fdotnet-development-on-a-mac-fusion-or-parallels%2F' data-shr_title='.NET+Development+on+a+Mac+-+Fusion+or+Parallels%3F'></a><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.marcuswhitworth.com%2F2009%2F09%2Fdotnet-development-on-a-mac-fusion-or-parallels%2F' data-shr_title='.NET+Development+on+a+Mac+-+Fusion+or+Parallels%3F'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.marcuswhitworth.com/2009/09/dotnet-development-on-a-mac-fusion-or-parallels/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 1/27 queries in 0.009 seconds using disk: basic
Object Caching 1305/1352 objects using disk: basic

Served from: www.marcuswhitworth.com @ 2012-02-06 22:02:17 -->
