<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>My Public Interface</title>
	
	<link>http://blog.roboblob.com</link>
	<description>and ideas for its refactoring...</description>
	<lastBuildDate>Mon, 25 Mar 2013 22:22:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/roboblob" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="roboblob" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Dot Net Gotcha #2 – Loop variables and Closures</title>
		<link>http://blog.roboblob.com/2012/09/30/dot-net-gotcha-nr2-loop-variables-and-closures/</link>
		<comments>http://blog.roboblob.com/2012/09/30/dot-net-gotcha-nr2-loop-variables-and-closures/#comments</comments>
		<pubDate>Sun, 30 Sep 2012 17:39:37 +0000</pubDate>
		<dc:creator>roboblob</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[DotNetGotcha]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[closure]]></category>
		<category><![CDATA[foreach]]></category>
		<category><![CDATA[lambda]]></category>
		<category><![CDATA[loops]]></category>

		<guid isPermaLink="false">http://blog.roboblob.com/?p=740</guid>
		<description><![CDATA[This one is my favorite.
Can you guess the output of this simple console application:
One would expect to see numbers from 0 to 9 but here is the actual output of the app:


OK that&#8217;s strange right?
It turns out its like that by design. What you have there is a Closure over the loop variable. And  [...]]]></description>
				<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://blog.roboblob.com/2012/09/30/dot-net-gotcha-nr2-loop-variables-and-closures/", "Dot Net Gotcha #2 – Loop variables and Closures", "" );
		//--></script></span><h2>This one is my favorite.</h2>
<p>Can you guess the output of this simple console application:</p>
<pre class="brush: plain; title: ; notranslate">
    class Program
    {
        static void Main()
        {
            var actions = new List();

            for (var i = 0 ; i &lt; 10; i++)             
            {                 
                var writeToConsoleAction = new Action(() =&gt;
                    {
                        Console.WriteLine(i);
                    });
                actions.Add(writeToConsoleAction);
            }

            foreach (var action in actions)
            {
                action();
            }

            Console.ReadLine();
        }
    }
</pre>
<p>One would expect to see numbers from 0 to 9 but here is the actual output of the app:</p>
<p><a href="http://blog.roboblob.com/wp-content/uploads/2012/09/loops-and-closures-gotcha-before1.jpg"><img class="alignleft size-full wp-image-752" style="clear: both; margin: 0px; display: block; float: none; border: 0px;" title="loops-and-closures-gotcha-before" src="http://blog.roboblob.com/wp-content/uploads/2012/09/loops-and-closures-gotcha-before1.jpg" alt="" width="416" height="239" /></a><br />
<a href="http://blog.roboblob.com/wp-content/uploads/2012/09/loops-and-closures-gotcha-before.jpg"><br />
</a>OK that&#8217;s strange right?</p>
<p>It turns out its like that by design. What you have there is a <strong><a title="Closure wiki" href="http://en.wikipedia.org/wiki/Closure_(computer_science)" target="_blank">Closure</a></strong> over the loop variable. And closures in C# are done around variables and not around specific values of those variables &#8211; so that means that lambda expression gets to use the actual reference to the closed variable.</p>
<h2>Let me explain in little bit more detail:</h2>
<p>In first loop we iterate increasing the <strong>counter</strong> variable from 0 to 9 and then use it in the lambda expression. That means each lambda gets its access to the <strong>counter</strong> via closure.</p>
<p>So at the end of this first loop, value of the counter is 10 (its 10 because we used post-increment operator: <strong>counter++</strong>, so in last iteration of the loop we increase counter to 10 and then check if its &lt;10 and we see its not, so we exit the loop).</p>
<p>Afterwards we start executing those actions we created in first loop, and they all have a Closure over this same variable <strong>counter</strong> &#8211; which has value of 10 and therefore each action prints out its current value 10 to the console.</p>
<p>So it works as expected, once you know what to expect. <img src='http://blog.roboblob.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>And this is really common mistake C# developers make.</p>
<h2>How to fix it?</h2>
<p>Solution is very simple once you know what is going on. All we need to do is this: instead of passing the variable <strong>counter</strong> to the lambda expression, create a local copy of this variable and pass this copy to the lambda instead of passing the <strong>counter</strong>.</p>
<p>That way, closure will each time be done around that copy variable that has current value of counter at that moment of execution, and this local copy value stay that way and will not be changed afterwards by the loop.</p>
<p>Later when the actions are executed (in the second loop), each will use their own closure around copy of the counter and therefore each will have its own different, expected value.</p>
<p>Here is the code that works as we expect:</p>
<pre class="brush: plain; title: ; notranslate">
    class Program
    {
        static void Main()
        {
            var actions = new List();

            for (var i = 0 ; i &lt; 10; i++)             
            {                 
                    int counterCopy = i;                 
                    var writeToConsoleAction = new Action(() =&gt;
                    {
                        Console.WriteLine(counterCopy);
                    });
                actions.Add(writeToConsoleAction);
            }

            foreach (var action in actions)
            {
                action();
            }

            Console.ReadLine();
        }
    }
</pre>
<p>As you see we create a copy of counter called <strong>counterCopy</strong> and pass this to the lambda expression each time.</p>
<p>Although this seems like old news if you knew it, there are many C# developers that are not aware of this behavior (or tend to forget it from time to time) so make sure to spread the word and always remember it.</p>
<p>By the way, the <a title="C# 5.0 changes how loop variables are used in closures" href="http://www.mindscapehq.com/blog/index.php/2012/03/18/what-else-is-new-in-c-5/" target="_blank">C# team is changing this in C# version 5 to work as one would expect</a> but until then we just need to copy those loop variables manually <img src='http://blog.roboblob.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/roboblob/~4/3GKT6JIbnKI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.roboblob.com/2012/09/30/dot-net-gotcha-nr2-loop-variables-and-closures/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dot Net Gotcha #1 – List versus Collection constructor</title>
		<link>http://blog.roboblob.com/2012/09/19/dot-net-gotcha-nr1-list-versus-collection-constructor/</link>
		<comments>http://blog.roboblob.com/2012/09/19/dot-net-gotcha-nr1-list-versus-collection-constructor/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 19:19:01 +0000</pubDate>
		<dc:creator>roboblob</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[DotNetGotcha]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.roboblob.com/?p=724</guid>
		<description><![CDATA[Don&#8217;t Google it!
Do you know (without Googling it) what will this console application display when executed?
If you try to think logically, you expect that both List and Collection will contain numbers from 1 to 6 when they are displayed, right?
Wrong, otherwise this would not be a proper gotcha   [...]]]></description>
				<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://blog.roboblob.com/2012/09/19/dot-net-gotcha-nr1-list-versus-collection-constructor/", "Dot Net Gotcha #1 &#8211; List versus Collection constructor", "" );
		//--></script></span><h2>Don&#8217;t Google it!</h2>
<p>Do you know (without Googling it) what will this console application display when executed?</p>
<pre class="brush: plain; title: ; notranslate">
    class Program
    {
        static void Main(string[] args)
        {
            var originalNumbers = new List&lt;int&gt; { 1, 2, 3, 4, 5, 6 };

            var list = new List&lt;int&gt;(originalNumbers);
            var collection = new Collection&lt;int&gt;(originalNumbers);

            originalNumbers.RemoveAt(0);

            DisplayItems(list, &quot;List items: &quot;);
            DisplayItems(collection, &quot;Collection items: &quot;);

            Console.ReadLine();
        }

        private static void DisplayItems(IEnumerable&lt;int&gt; items, string title)
        {
            Console.WriteLine(title);
            foreach (var item in items)
                Console.Write(item);
            Console.WriteLine();
        }
    }
</pre>
<p>If you try to think logically, you expect that both List and Collection will contain numbers from 1 to 6 when they are displayed, right?</p>
<p>Wrong, otherwise this would not be a proper gotcha <img src='http://blog.roboblob.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Here is the actual output of the application (surprise, surprise):</p>
<p><a style="border: 0px; display: block; float: none;" href="http://blog.roboblob.com/wp-content/uploads/2012/09/dot-net-gotcha-nr1-list-versus-collection-constructor1.jpg"><img class="alignleft size-full wp-image-730" style="border: 0px; display: block; float: none;" title="dot-net-gotcha-nr1-list-versus-collection-constructor" src="http://blog.roboblob.com/wp-content/uploads/2012/09/dot-net-gotcha-nr1-list-versus-collection-constructor1.jpg" alt="" width="713" height="371" /></a></p>
<p>Do you know why?</p>
<p>Answer is actually very simple. If you check the <a title="MSDN documentation for Collection constructor that accepts IList" href="http://msdn.microsoft.com/en-us/library/ms132401(v=vs.80).aspx" target="_blank">MSDN documentation for Collection constructor that accepts generic IList </a>you will see this text:</p>
<blockquote><p>Initializes a new instance of the Collection class as a wrapper for the specified list.</p></blockquote>
<p>That means that this constructor creates just a wrapper around the existing IList, so adding or removing items to the original list will also affect the new Collection we just created,  because its just a wrapper and uses original List under the hood.</p>
<p>On the other hand <a title="MSDN documentation on List constructor that accepts IEnumerable&lt;T&gt;" href="http://msdn.microsoft.com/en-us/library/fkbw11z0.aspx" target="_blank">List constructor that accepts IEnumerable&lt;T&gt;</a> behaves properly and does what you would logically expect it to do:</p>
<blockquote><p>Initializes a new instance of the List&lt;T&gt; class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied.</p></blockquote>
<p>So when you create a new List and pass an existing List to its constructor it will create a proper new empty list, and then copy all the references from original List to the new List.</p>
<p>Because of that, the new List is &#8216;detached&#8217; from the original and this is why it remains unchanged even if we modify the original List.</p>
<h2>Moral of the story</h2>
<p>This is simply how Microsoft made these two classes (i would not say its very consistent or good but who am i to judge, right?) and as long as you know it &#8211; its fine.</p>
<p>And if you don&#8217;t know this &#8211; it can bite you really hard.</p>
<p>All that you can do is to try to remember this, and also: <a title="RTFM" href="http://en.wikipedia.org/wiki/RTFM">RTFM</a>.</p>
<p>Btw, did i said that this can be an excellent job interview question?   <img src='http://blog.roboblob.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Until next Dot Net Gotcha, keep reading those manuals&#8230;</p>
<img src="http://feeds.feedburner.com/~r/roboblob/~4/aem4FM18q7w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.roboblob.com/2012/09/19/dot-net-gotcha-nr1-list-versus-collection-constructor/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Another way to close Windows Phone application from code</title>
		<link>http://blog.roboblob.com/2012/08/21/another-way-to-close-windows-phone-application/</link>
		<comments>http://blog.roboblob.com/2012/08/21/another-way-to-close-windows-phone-application/#comments</comments>
		<pubDate>Tue, 21 Aug 2012 16:17:32 +0000</pubDate>
		<dc:creator>roboblob</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Navigation]]></category>
		<category><![CDATA[Offline Browser]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://blog.roboblob.com/?p=714</guid>
		<description><![CDATA[
Correction
In my previous post on how to terminate the Windows Phone application i proposed a solution that is not really in accordance with Windows Phone Marketplace Technical Cerification Requirements (see requirement 5.1.2):
&#8221; An application that closes unexpectedly fails certification. &#8221;
Even  [...]]]></description>
				<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://blog.roboblob.com/2012/08/21/another-way-to-close-windows-phone-application/", "Another way to close Windows Phone application from code", "" );
		//--></script></span><hr style="height: 1px; width: 1px; border-width: 1px; border-style: solid; border-color: #CCCCCC; color: #ffffff;" noshade="noshade" size="1" width="1" />
<h2>Correction</h2>
<p>In my <a title="post on how to terminate the Windows Phone application" href="http://blog.roboblob.com/2012/08/19/how_to_terminate_your_windows_phone_application_programmatically/" target="_blank">previous post on how to terminate the Windows Phone application</a> i proposed a solution that is not really in accordance with Windows Phone <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh184840(v=vs.92).aspx" target="_blank">Marketplace Technical Cerification Requirements</a> (see requirement 5.1.2):</p>
<p>&#8221; An application that closes unexpectedly fails certification. &#8221;</p>
<p>Even though I&#8217;m pretty sure that this requirement is not enforced since my apps use this approach and they were never rejected i decided to present another way.</p>
<p>Some good people suggested in <a href="http://blog.roboblob.com/2012/08/19/how_to_terminate_your_windows_phone_application_programmatically/#comments">comments of my previous post</a> that you can terminate current application  simply by calling the <a title="MSDN Game class Exit method definition" href="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.exit" target="_blank">XNA Game class Exit method</a> like this:</p>
<pre class="brush: csharp; title: ; notranslate">
using Microsoft.Xna.Framework;

namespace Roboblob
{
    public class AppLifetimeHelper
    {
        public void CloseApplication()
        {
            new Game().Exit();
        }
    }
}
</pre>
<p>The downside of this is that you need to add 2 XNA dll&#8217;s to your project:</p>
<ol>
<li><span style="line-height: 18px;">Microsoft.Xna.Framework</span></li>
<li><span style="line-height: 18px;">Microsoft.Xna.Framework.Game</span></li>
</ol>
<div>So there you have both approaches and you can choose which one is better for you until Microsoft exposes standardized way of closing application from code (i hope this will happen in Windows Phone 8 APIs).</div>
<div><span style="line-height: 18px;"><br />
</span></div>
<img src="http://feeds.feedburner.com/~r/roboblob/~4/FTHMqMMcvZ4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.roboblob.com/2012/08/21/another-way-to-close-windows-phone-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to terminate your Windows Phone application programmatically?</title>
		<link>http://blog.roboblob.com/2012/08/19/how_to_terminate_your_windows_phone_application_programmatically/</link>
		<comments>http://blog.roboblob.com/2012/08/19/how_to_terminate_your_windows_phone_application_programmatically/#comments</comments>
		<pubDate>Sun, 19 Aug 2012 12:33:41 +0000</pubDate>
		<dc:creator>roboblob</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Navigation]]></category>
		<category><![CDATA[Offline Browser]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Api]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[inavigationframework]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[Prism Navigation Framework]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://blog.roboblob.com/?p=696</guid>
		<description><![CDATA[Its weird how in Windows Phone API there is no way to easily terminate your current application.
I guess makers of the platform did not wanted us developers to mingle with the application lifetime too much, phone should decide when an app is not needed and terminate it.

But i just simply cannot help myself, i always like to have full control, for example in my Offline Browser application i want to end the app if user presses the hardware Back Key multiple times in short time intervals...]]></description>
				<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://blog.roboblob.com/2012/08/19/how_to_terminate_your_windows_phone_application_programmatically/", "How to terminate your Windows Phone application programmatically?", "" );
		//--></script></span><hr style="width: 0px; border-width: 1px; border-style: solid; border-color: #CCCCCC; color: #ffffff;" noshade="noshade" width="0" />
<p><span style="color: #ff0000;">21/08/2012 Update: </span></p>
<p>There is another way to close the Windows Phone application without throwing exception see more details in <a title="Another way to terminate windows phone application" href="http://blog.roboblob.com/2012/08/21/another-way-to-close-windows-phone-application/">my next post</a>.</p>
<h2>We want full power!</h2>
<p>Its known that in Windows Phone API there is no easy way to terminate the current application from your code.</p>
<p>I guess makers of the platform did not wanted us developers to mingle with the application lifetime too much, phone should decide when an app is not needed and terminate it.</p>
<p>But i just simply cannot help myself, i always like to have full control, for example in my <a title="Offline Browser for Windows Phone" href="http://offlinebrowser.roboblob.com/">Offline Browser</a> application i want to end the app if user presses the hardware Back Key multiple times in short time intervals.</p>
<p>Because there is this annoying situation when user goes navigating between the pages in your app (main screen, then settings, then about screen,</p>
<p>then again main screen etc) and then when he wants to terminate it he need to click the hardware back button N number of times in order to close it.</p>
<p>And even in some other situations its needed to force close the app, for example if some change in application settings requires app restart etc.</p>
<h2>Show Us The Code!</h2>
<p>So i decided to change this and wrote this simple AppLifetimeHelper that allows you to terminate your current app without any delay.</p>
<p>How it works is that it uses <a title="RootVisual class on MSDN" href="http://msdn.microsoft.com/en-us/library/system.windows.application.rootvisual(v=vs.95).aspx" target="_blank">Application.Current.RootVisual</a> and casts it to <a title="PhoneApplicationFrame class on MSDN" href="http://msdn.microsoft.com/en-us/library/microsoft.phone.controls.phoneapplicationframe(v=vs.92).aspx" target="_blank">PhoneApplicationFrame</a> that has RemoveBackEntry method that basically simulates</p>
<p>the users hardware Back Key press and then in endless loop it calls this method until the navigation back stack of the app is empty.</p>
<p>Then all we need to do is to call the GoBack method of the PhoneApplicationFrame and it will terminate the app since there are no more entries in the app Back Stack.</p>
<p>Simple or what?   <img src='http://blog.roboblob.com/wp-includes/images/smilies/icon_cool.gif' alt='8-)' class='wp-smiley' /> </p>
<p>So here is the code if you AppLifetimeHelper that you can freely use in your apps if you need this functionality:</p>
<pre class="brush: csharp; title: ; notranslate">

using System.Linq;
using System.Windows;
using Microsoft.Phone.Controls;

namespace Roboblob
{
    public class AppLifetimeHelper
    {
        public void CloseApplication()
        {
            ClearApplicationNavigationBackStack();
            Root.GoBack();
        }

        private PhoneApplicationFrame _root;
        private PhoneApplicationFrame Root
        {
            get
            {
                if (_root == null)
                {
                    _root = Application.Current.RootVisual as PhoneApplicationFrame;
                }

                return _root;
            }
        }

        private void ClearApplicationNavigationBackStack()
        {
            if (Root == null)
            {
                return;
            }

            try
            {
                while (Root.BackStack.Any())
                {
                    Root.RemoveBackEntry();
                }
            }
            catch
            { }
        }
    }
}
</pre>
<h2>And if you are really lazy today&#8230;</h2>
<p>Here is the <a href="http://blog.roboblob.com/manual-uploads/VisualStudioSolutions/CloseWindowsPhoneAppSolution.zip">download link to the Visual Studio solution</a> with Windows Phone application that uses this helper to terminate it self when a button is clicked&#8230;</p>
<img src="http://feeds.feedburner.com/~r/roboblob/~4/PPRM_bsKklQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.roboblob.com/2012/08/19/how_to_terminate_your_windows_phone_application_programmatically/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Using Instapaper and other Mobilizer services in Offline Browser for Windows Phone</title>
		<link>http://blog.roboblob.com/2012/06/16/using-instapaper-and-other-mobilizer-services-in-offline-browser-for-windows-phone/</link>
		<comments>http://blog.roboblob.com/2012/06/16/using-instapaper-and-other-mobilizer-services-in-offline-browser-for-windows-phone/#comments</comments>
		<pubDate>Fri, 15 Jun 2012 23:33:30 +0000</pubDate>
		<dc:creator>roboblob</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Offline Browser]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[instapaper]]></category>

		<guid isPermaLink="false">http://blog.roboblob.com/?p=671</guid>
		<description><![CDATA[Mobile is the future!
Its a known fact that mobile usage of internet is growing.
More and more people are using primarily their phones and tablets to browse the web. Yet many websites are still not optimized for small screen devices.
My application Offline Browser for Windows Phone allows you to  [...]]]></description>
				<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://blog.roboblob.com/2012/06/16/using-instapaper-and-other-mobilizer-services-in-offline-browser-for-windows-phone/", "Using Instapaper and other Mobilizer services in Offline Browser for Windows Phone", "" );
		//--></script></span><h2>Mobile is the future!</h2>
<p>Its a known fact that <a title="Mobile usage of internet is growing" href="http://www.smartinsights.com/mobile-marketing/mobile-marketing-analytics/mobile-marketing-statistics/" target="_blank">mobile usage of internet is growing</a>.</p>
<p>More and more people are using primarily their phones and tablets to browse the web. Yet many websites are still not optimized for small screen devices.</p>
<p>My application <a href="http://offlinebrowser.roboblob.com/" target="_blank">Offline Browser for Windows Phone</a> allows you to save whole web pages for later offline reading, but what to do if the website is not optimized for mobile devices?</p>
<h2>Mobilize it!</h2>
<p>This is where the concept of Mobilizer Services comes in.</p>
<p>Offline Browser supports multiple web services that can transform given web page into simpler version, where only content and images are kept and all other &#8216;noise&#8217; is removed.</p>
<p>Here is the list of currently supported Mobilizers:</p>
<ol>
<li><a title="Instapaper" href="http://www.instapaper.com" target="_blank">Instapaper</a> &#8211; currently the best option, creates clean output and preserves images</li>
<li><a title="Google Mobilizer" href="http://www.google.com/gwt/n" target="_blank">Google Mobilizer</a> &#8211; not so nice because it pages the content</li>
<li>ReadItLater (now known as <a title="Pocket (before called ReadItLater)" href="http://getpocket.com/" target="_blank">Pocket</a>) &#8211; very nice but removes images</li>
</ol>
<p>Each of those services are different and they give better or worse results when simplifying the webpage content &#8211; it often varies from website to website.</p>
<p>I prefer Instapaper since it gives cleanest output and shows images but you should try each of them to see which one is best for webpages you are opening.</p>
<p>Important thing to note here is that when Offline Browser uses these Mobilizer services to get the simplified content of web pages, all the images are saved to the phone and are available later when you view those pages when offline.</p>
<p>Another benefit of using Mobilizer service is that they reduce the bandwidth usage so if you have some tariff plan with limited number of MB this could help you keep the bandwidth usage as low as possible &#8211; not to mention that saving pages via Mobilizer is much faster!</p>
<h2>So how do we enable this cool feature?</h2>
<p>We just go to the Offline Browser Settings page and switch on this feature and choose which Mobilizer service we want to use.</p>
<p>Here is how this screen looks on the Windows Phone:</p>
<p><a style="display: block; float: none;" href="http://blog.roboblob.com/wp-content/uploads/2012/06/Screen-Capture-49.jpg"><img class="alignleft  wp-image-686" style="float: none; clear: left; margin: 10px;" title="Offline Browser Mobilizers Settings" src="http://blog.roboblob.com/wp-content/uploads/2012/06/Screen-Capture-49.jpg" alt="" width="240" height="400" /></a></p>
<p>Once we enable the Mobilizer service all the pages we save to the phone storage are retrieved via the chosen Mobilizer and when you actually read the page you will see the mobilized version instead of the full webpage.</p>
<p>Here is how one of the web pages looks before using mobilizer:</p>
<p><a href="http://blog.roboblob.com/wp-content/uploads/2012/06/Screen-Capture-52.jpg" rel="linkel lightbox[obfp]"><img class="alignleft  wp-image-687" style="float: none; clear: left; margin: 10px;" title="Page not optimized for mobile" src="http://blog.roboblob.com/wp-content/uploads/2012/06/Screen-Capture-52.jpg" alt="" width="240" height="400" /></a></p>
<p>As you can see webpage is not optimized for mobile devices and its not easy to read on the phone.</p>
<p>I deliberately used desktop browser user agent in the app Settings just to prove the point.</p>
<p>If we now switch to using Instapaper Mobilizer in the app Settings (and we still use the same desktop browser user agent) we will get completely different content:</p>
<p><a href="http://blog.roboblob.com/wp-content/uploads/2012/06/Screen-Capture-54.jpg" rel="linkel lightbox[obfp]"><img class="alignleft  wp-image-688" style="float: none; clear: left; margin: 10px;" title="Page saved via Instapaper Mobilizer" src="http://blog.roboblob.com/wp-content/uploads/2012/06/Screen-Capture-54.jpg" alt="" width="240" height="400" /></a></p>
<p>As you see page is much easier to read, all the images are preserved.</p>
<p>Yet page is saved faster and less bandwidth is wasted.</p>
<h2>So why not always use it?</h2>
<p>Well i do use this all the time and only when Mobilizer services fail to retrieve content of some web page, then i switch it off and load original page content.</p>
<p>It all depends on your usage scenario and also on your data plan limits/internet connection speed etc.</p>
<p>Important thing is that you do have a choice and you can setup Offline Browser to work how its most convenient for you.</p>
<p>If you have any feedback regarding Mobilizers feature or you know of some good Mobilizer service that i should include in the app please <a href="http://offlinebrowser.uservoice.com/forums/162559-general">send me a feedback via the Offline Browser Uservoice page</a> and i will be glad to include it!</p>
<img src="http://feeds.feedburner.com/~r/roboblob/~4/hpAuD8a5H98" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.roboblob.com/2012/06/16/using-instapaper-and-other-mobilizer-services-in-offline-browser-for-windows-phone/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Throttling Immediate TextBox Binding Behavior for Windows Phone</title>
		<link>http://blog.roboblob.com/2012/06/05/throttling-immediate-textbox-binding-behavior-for-windows-phone/</link>
		<comments>http://blog.roboblob.com/2012/06/05/throttling-immediate-textbox-binding-behavior-for-windows-phone/#comments</comments>
		<pubDate>Tue, 05 Jun 2012 20:17:24 +0000</pubDate>
		<dc:creator>roboblob</dc:creator>
				<category><![CDATA[Behavior]]></category>
		<category><![CDATA[CustomControl]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[MVVM]]></category>
		<category><![CDATA[Offline Browser]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Mvvvm]]></category>

		<guid isPermaLink="false">http://blog.roboblob.com/?p=651</guid>
		<description><![CDATA[The learning curve of a Windows Phone developer
While developing Offline Web Browser for Windows Phone i had to build a small MVVM framework in order to keep the logic out of the views.
One of the first thing i found missing was a way to force immediate propagation of text entered in TextBox  [...]]]></description>
				<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://blog.roboblob.com/2012/06/05/throttling-immediate-textbox-binding-behavior-for-windows-phone/", "Throttling Immediate TextBox Binding Behavior for Windows Phone", "" );
		//--></script></span><h2>The learning curve of a Windows Phone developer</h2>
<p>While developing <a title="Offline Web Browser application for Windows Phone" href="http://offlinebrowser.roboblob.com/" target="_blank">Offline Web Browser for Windows Phone</a> i had to build a small MVVM framework in order to keep the logic out of the views.</p>
<p>One of the first thing i found missing was a way to force immediate propagation of text entered in TextBox control to the databound property of my ViewModel.</p>
<p>By default, TextBox binding is triggered only when control loses focus, and this is kind of lame.</p>
<h2>Code reuse is not a myth!</h2>
<p>This is really old problem. It existed in desktop Silverlight from the beginning. And it made its way to the Windows Phone platform.</p>
<p>Fortunately I remembered that back in the days while experimenting with Silverlight MVVM framework <a href="http://blog.roboblob.com/2010/07/16/custom-silverlight-textbox-control-that-immediately-updates-databound-text-property-in-twoway-binding/" target="_blank">i already solved this problem by creating a custom silverlight TextBox control</a> so i decided to just reuse that code and create a Behavior that will force binding update to fire on each keystroke in TextBox.</p>
<p>That&#8217;s the beauty of developing a Windows Phone app &#8211; you can reuse most of the Silverlight code you built over the years <img src='http://blog.roboblob.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>But then i noticed another problem. Because now each keystroke was propagating changes to my ViewModel, if user would type fast and i do for example some web service call on each property change &#8211; then i can have too many requests to the web service (one for each keystroke) but in fact i want to do a call only when user stopped typing for a while.</p>
<p>Fortunately, solution is very simple &#8211; we will use <a href="http://msdn.microsoft.com/en-us/data/gg577609.aspx">Reactive Extensions (Rx)</a> since its perfect fit and its already built-in into Windows Phone.</p>
<p>We just need to reference Microsoft.Phone.Reactive.dll from GAC (no additional download needed) and we are half-way there.</p>
<h2>OK, but show us some code!</h2>
<p>Yes lets see how the code for the ThrottledImmediateBindingBehavior looks like:</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Interactivity;
using Microsoft.Phone.Reactive;

namespace Roboblob.Mvvm.Behaviors
{
    public class ThrottledImmediateBindingBehavior : Behavior
    {
        private BindingExpression _expression;

        public bool Throttle { get; set; }

        private double _throttleDelayInSeconds = 0.5;
        private IDisposable _currentObservable;

        public double ThrottleDelayInSeconds
        {
            get { return _throttleDelayInSeconds; }
            set { _throttleDelayInSeconds = value; }
        }

        protected override void OnAttached()
        {
            base.OnAttached();

            if (Throttle)
            {
                this._expression = this.AssociatedObject.GetBindingExpression(TextBox.TextProperty);
                var keys = Observable.FromEvent(AssociatedObject, &quot;TextChanged&quot;).Throttle(TimeSpan.FromSeconds(ThrottleDelayInSeconds));
                _currentObservable = keys.ObserveOn(Deployment.Current.Dispatcher).Subscribe(evt =&gt; OnTextChanged(evt.Sender, evt.EventArgs));
            }
            else
            {
                this._expression = this.AssociatedObject.GetBindingExpression(TextBox.TextProperty);
                this.AssociatedObject.TextChanged += this.OnTextChanged;
            }
        }

        protected override void OnDetaching()
        {
            base.OnDetaching();

            if (Throttle)
            {
                if (_currentObservable != null)
                {
                    _currentObservable.Dispose();
                    this._expression = null;
                }
            }
            else
            {
                this.AssociatedObject.TextChanged -= this.OnTextChanged;
                this._expression = null;
            }
        }

        private void OnTextChanged(object sender, EventArgs args)
        {
            if (_expression != null)
            {
                this._expression.UpdateSource();
            }
        }
    }
}

</pre>
<h2>Simple Is Beautiful</h2>
<p>Our Binding class has bool property Throttle where we can enable/disable throttling and also a ThrottleDelayInSeconds where we specify after how many seconds later after user stops typing our property is updated.</p>
<p>In the OnAttached &#8211; we just hook to the TextChanged and each time user types something we update the binding source.</p>
<p>But if Throttle is set to true, we hook to the TextChanged event over Reactive Extensions and we setup throttling so that binding do not trigger if changes are too fast.</p>
<p>In this only after changes stop firing for the time defined in ThrottleDelayInSeconds, only then binding update is triggered.</p>
<p>Off course we do a little cleanup in the OnDetaching as all good coders <img src='http://blog.roboblob.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>What about the Xaml???</h2>
<p>Yes in Xaml we can use it like this:</p>
<pre class="brush: xml; title: ; notranslate">
            &lt;TextBox Text=&quot;{Binding SearchCriteriaText, Mode=TwoWay}&quot;&gt;
                &lt;i:Interaction.Behaviors&gt;
                    &lt;RoboblobBehaviors:ThrottledImmediateBindingBehavior Throttle=&quot;True&quot; ThrottleDelayInSeconds=&quot;1&quot; /&gt;
                &lt;/i:Interaction.Behaviors&gt;
            &lt;/TextBox&gt;
</pre>
<p>For those who are lazy to type I&#8217;m attaching a <a href="http://blog.roboblob.com/manual-uploads/VisualStudioSolutions/ImmediateThrottledTextboxBindingWindowsPhone.zip">zipped source code of simple Windows Phone Mango project</a> that is demonstrating the usage of the behavior.</p>
<p>Btw does somebody even remember how it was to type source code from printed computer magazines int your 8bit computer?</p>
<p>Probably not <img src='http://blog.roboblob.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Well at least I hope that someone will find this useful.</p>
<p>Until next time, happy coding!</p>
<img src="http://feeds.feedburner.com/~r/roboblob/~4/DP_m1bKmID4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.roboblob.com/2012/06/05/throttling-immediate-textbox-binding-behavior-for-windows-phone/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using Offline Browser for Windows Phone as Instapaper client</title>
		<link>http://blog.roboblob.com/2012/05/29/using-offline-browser-for-windows-phone-as-instapaper-client/</link>
		<comments>http://blog.roboblob.com/2012/05/29/using-offline-browser-for-windows-phone-as-instapaper-client/#comments</comments>
		<pubDate>Tue, 29 May 2012 20:33:30 +0000</pubDate>
		<dc:creator>roboblob</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Offline Browser]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://blog.roboblob.com/?p=625</guid>
		<description><![CDATA[Lets set some expectations here. We wont be adding new items to Instapaper.com reading list or removing items or anything similar.

We can use our desktop PC for that.

Here we will just explain how to use Offline Browser for Windows Phone to get all those links from Instapaper.com reading list via RSS feed and download them to the phone so we can read them whenever we want - even when we are offline.]]></description>
				<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://blog.roboblob.com/2012/05/29/using-offline-browser-for-windows-phone-as-instapaper-client/", "Using Offline Browser for Windows Phone as Instapaper client", "" );
		//--></script></span><p>&nbsp;</p>
<p>&nbsp;</p>
<p>Lets set some expectations here. We wont be adding new items to <a href="http://instapaper.com">Instapaper.com</a> reading list or removing items or anything similar.</p>
<p>We can use our desktop PC for that.</p>
<p>Here we will just explain how to use <a href="http://offlinebrowser.roboblob.com/" target="_blank">Offline Browser for Windows Phone</a> to get all those links from Instapaper.com reading list via RSS feed and download them to the phone so we can read them whenever we want &#8211; even when we are offline.</p>
<p>So first we need to add the Instapaper unread items Rss feed into Offline Browser as a Links Feed.</p>
<p>Here is how you can do that:</p>
<p>1. Open the Offline Browser for Windows Phone and on the Browser page go to Instapaper.com and login to your account.</p>
<p>Once you are logged in, you will be redirected to this url: <a href="http://www.instapaper.com/u">http://www.instapaper.com/u</a> which is your unread items list.</p>
<p>2. Now we should find the RSS feed of your unread Instapaper items and use it as links source (Link Feed) of the Offline Browser app.</p>
<p>The RSS feed icon and link are at the bottom right corner of the <a href="http://Instapaper.com/u" target="_blank">http://Instapaper.com/u</a> web page, take a look at the screenshot below:</p>
<p><a style="display: block; float: none;" href="http://blog.roboblob.com/wp-content/uploads/2012/05/ThisFolderRss.jpg" rel="rel=&quot;lightbox[obinstapaper]&quot;"><img class=" wp-image-629 alignleft" style="margin: 10px; display: block; float: none;" title="Instapaper Unread Items Rss Feed" src="http://blog.roboblob.com/wp-content/uploads/2012/05/ThisFolderRss.jpg" alt="" width="240" height="400" /></a></p>
<p>3. Now long tap that link &#8216;This folder&#8217;s RSS&#8217; and context menu of Offline Browser will appear:</p>
<p><a class="margin: 10px; display: block; float:none" href="http://blog.roboblob.com/wp-content/uploads/2012/05/Screen-Capture-40.jpg" rel="rel=&quot;lightbox[obinstapaper]&quot;"><img class="alignleft  wp-image-634" style="margin: 10px; display: block; float: none;" title="Offline Browser Context Menu" src="http://blog.roboblob.com/wp-content/uploads/2012/05/Screen-Capture-40.jpg" alt="" width="240" height="400" /></a></p>
<p>4. Click on the &#8220;Add Link as Links Feed&#8221; item and RSS feed of your unread instapaper items will be added as Links Feed for the Offline Browser.</p>
<p><a style="display: block; float: none;" href="http://blog.roboblob.com/wp-content/uploads/2012/05/Screen-Capture-42.jpg" rel="rel=&quot;lightbox[obinstapaper]&quot;"><img class="alignleft  wp-image-635" style="margin: 10px; display: block; float: none;" title="Instapaper Rss Feed added as Links Feed in Offline Browser for Windows Phone" src="http://blog.roboblob.com/wp-content/uploads/2012/05/Screen-Capture-42.jpg" alt="" width="240" height="400" /></a></p>
<p>5. Now lets enable Links Feed synchronization in settings:</p>
<p><a class="margin: 10px; display: block; float:none" href="http://blog.roboblob.com/wp-content/uploads/2012/05/Screen-Capture-41.jpg" rel="lightbox[obfp]"><img class="alignleft  wp-image-636" style="margin: 10px; display: block; float: none;" title="Link Feeds settings tab in Offline Browser" src="http://blog.roboblob.com/wp-content/uploads/2012/05/Screen-Capture-41.jpg" alt="" width="240" height="400" /></a></p>
<p>There we see the RSS feed from instapaper added to the app as Link Feed and we see that background downloading of the URLs from the feeds is enabled and done every 2 hours.</p>
<p>So even if our application is not running, a background task will retrieve the RSS feed and if there are new links they will all be added to the download queue.</p>
<p>When this happens you will get a toast notification and live tile of the Offline Browser will show number of new links retrieved from all feeds.</p>
<p>Here is how this looks on the Windows Phone start screen:</p>
<p><a class="margin: 10px; display: block; float: none;" href="http://blog.roboblob.com/wp-content/uploads/2012/05/Screen-Capture-47.jpg" rel="rel=&quot;lightbox[obinstapaper]&quot;"><img class="alignleft  wp-image-638" style="margin: 10px; display: block; float: none;" title="Offline Browser Live Tile Showing Download Queue Count" src="http://blog.roboblob.com/wp-content/uploads/2012/05/Screen-Capture-47.jpg" alt="" width="240" height="400" /></a></p>
<p>6. When we click on the Offline Browser icon and there are new items to download we are immediately taken to the download queue screen.</p>
<p>There you can simply click on the Sync button and all new links from download queue will be downloaded.</p>
<p>(app will also check if there are some newer items in the feed and retrieve them together with the items that are already in the download queue).</p>
<p><a style="display: block; float: none;" href="http://blog.roboblob.com/wp-content/uploads/2012/05/Screen-Capture-43.jpg" rel="rel=&quot;lightbox[obinstapaper]&quot;"><img class="alignleft  wp-image-639" style="display: block; float: none;" title="Download Queue in Offline Browser showing one item from Instapaper" src="http://blog.roboblob.com/wp-content/uploads/2012/05/Screen-Capture-43.jpg" alt="" width="240" height="400" /></a></p>
<p>Once pages are downloaded we can go to the saved pages screen and open them in the browser screen:</p>
<p><a style="display: block; float: none;" href="http://blog.roboblob.com/wp-content/uploads/2012/05/Screen-Capture-46.jpg" rel="rel=&quot;lightbox[obinstapaper]&quot;"><img class="alignleft  wp-image-640" style="display: block; float: none;" title="Page opened in the Offline Browser" src="http://blog.roboblob.com/wp-content/uploads/2012/05/Screen-Capture-46.jpg" alt="" width="240" height="400" /></a></p>
<p>Its important to say that once you go through this process and your instapaper RSS feed is added to the app, it becomes automatic and phone will download any links you add to your instapaper reading list.</p>
<p>So now that you know how you can use <a href="http://offlinebrowser.roboblob.com/">Offline Browser</a> as your Instapaper client &#8211; go ahead, <a href="http://windowsphone.com/s?appid=e34e28aa-b6bc-48f5-b3f8-62f0dc41757f" target="_blank">download it from marketplace</a> and give it a try!</p>
<img src="http://feeds.feedburner.com/~r/roboblob/~4/nruoyM42mg4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.roboblob.com/2012/05/29/using-offline-browser-for-windows-phone-as-instapaper-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Offline Browser for Windows Phone is released</title>
		<link>http://blog.roboblob.com/2012/05/26/offline-browser-for-windows-phone-is-released/</link>
		<comments>http://blog.roboblob.com/2012/05/26/offline-browser-for-windows-phone-is-released/#comments</comments>
		<pubDate>Sat, 26 May 2012 11:50:07 +0000</pubDate>
		<dc:creator>roboblob</dc:creator>
				<category><![CDATA[Certification]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Offline Browser]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Browser]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Marketplace]]></category>
		<category><![CDATA[Offline]]></category>
		<category><![CDATA[Web Browser]]></category>

		<guid isPermaLink="false">http://blog.roboblob.com/?p=539</guid>
		<description><![CDATA[ 
Here is some good news:
finally my Windows Phone application Offline Browser is available for download in the Windows Phone Marketplace!
Offline Web Browser? But who needs that?
Well actually i do. To be honest app was created (as many other apps) in order &#8216;to scratch an itch&#8216;.
I&#8217;m an old  [...]]]></description>
				<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://blog.roboblob.com/2012/05/26/offline-browser-for-windows-phone-is-released/", "Offline Browser for Windows Phone is released", "" );
		//--></script></span><h3> </h3>
<p>Here is some good news:</p>
<p>finally my Windows Phone application <a title="Offline Browser For Windows Phone Website Home Page" href="http://offlinebrowser.roboblob.com/" target="_blank">Offline Browser</a> is <a title="Offline Browser For Windows Phone in Marketplace" href="http://windowsphone.com/s?appid=e34e28aa-b6bc-48f5-b3f8-62f0dc41757f" target="_blank">available for download in the Windows Phone Marketplace</a>!</p>
<h2>Offline Web Browser? But who needs that?</h2>
<p>Well actually i do. To be honest app was created (as many other apps) in order &#8216;<strong>to scratch an itch</strong>&#8216;.</p>
<p>I&#8217;m an old information junkie and while traveling to work i like reading books and surfing the web, but often i don&#8217;t have internet connection or its very slow (for example when I&#8217;m in the subway).</p>
<p>Although there are many excellent E-Book readers for Windows Phone (one of the best is for sure <a title="Freda EBook reader" href="http://www.turnipsoft.co.uk/freda/" target="_blank">Freda</a>) i could not find a single offline internet web browser that would allow me to save full content of web pages to my phone and read them later when I&#8217;m offline.</p>
<p>This is how idea for Offline Browser for Windows Phone was born.</p>
<h2>Here are some of Offline Browser current features:</h2>
<ul>
<li>save to your phone full content of web pages (HTML content with all images, CSS Style Sheets, JScript etc)</li>
<li>later view all saved pages even when you are offline</li>
<li>all links between saved pages work even when you are offline</li>
<li>save all the links that are on current page with one click (useful for online news/magazines that have many links to related content)</li>
<li>long tap gesture on link/image shows context menu with additional options for that link/image</li>
<li>automatic retrieval of links for download queue by adding RSS or Atom feeds as source (add your Instapaper or Delicious or any other feed)</li>
<li>download all queued links by Sync option</li>
<li>change Browser User Agent (mobile or desktop Internet Explorer, IPhone or any other custom string)</li>
<li>save pages via Mobilizer service (Instapaper, ReadItLater, Google Mobilizer etc)</li>
<li>page scroll position is preserved so when you later open saved page its scrolled down exactly where you were last time</li>
<li>its simple to use and can completely replace built in Internet Explorer browser since its uses same page rendering engine but adds more features</li>
</ul>
<p>So now that we have an overview of what the app does, lets see how it looks and works:</p>
<h2>The main browser page</h2>
<p>First and main application screen is the Browser page and this is where most of the magic happens:</p>
<p><a href="http://blog.roboblob.com/wp-content/uploads/2012/05/OfflineBrowserMainPage.jpg" rel="lightbox[obfp]"><img class="size-full wp-image-545 alignleft" style="margin: 10px; clear: both;" title="Offline Browser Main Page" src="http://blog.roboblob.com/wp-content/uploads/2012/05/OfflineBrowserMainPage.jpg" alt="" width="240" height="400" /></a></p>
<p>As you can see UI is minimal.</p>
<p>I wanted to be able to focus on the page I&#8217;m currently viewing and not on the UI elements of the app.</p>
<p>Its very similar to the stock phone browser and icons do not cover too much of the screen space.</p>
<p>The main feature of the app is the Save button at the bottom of the page (annotated in the screenshot with the red arrow).</p>
<p>By pressing this button the whole page is downloaded to the phone with all the content including images etc.</p>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2>Sliding Menu on the bottom of Browser page:</h2>
<p><a href="http://blog.roboblob.com/wp-content/uploads/2012/05/OfflineBrowserBottomMenu.jpg" rel="lightbox[obfp]"><img class="alignleft  wp-image-546" style="margin: 10px; clear: both;" title="Offline Browser Bottom Menu" src="http://blog.roboblob.com/wp-content/uploads/2012/05/OfflineBrowserBottomMenu.jpg" alt="" width="240" height="400" /></a></p>
<p>When we click on the three dots in the lower right corner the sliding menu appears at the bottom with links to the other pages in the app and additional options available for this web page.</p>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<hr style="width: 0px;" width="0" />
<h2> </h2>
<h2>Browser Context Menu</h2>
<p>When we do a long tap on any link or image on the web page a context menu appears with additional options available for link/image.</p>
<p><a href="http://blog.roboblob.com/wp-content/uploads/2012/05/screenshot3.jpg" rel="lightbox[obfp]"><img class="alignleft size-full wp-image-547" style="border: 1px solid black; margin: 10px;" title="Offline Browser Context Menu" src="http://blog.roboblob.com/wp-content/uploads/2012/05/screenshot3.jpg" alt="" width="240" height="400" /></a></p>
<p>We can save all the links pointing to the same domain and share the link URL over phone email or social networks accounts.</p>
<p>Images can be saved to the phone Media Library.</p>
<p>Also you can add link as your link feed URL. So you can just long tap on some RSS/Atom feed URL and add it as a source for new links for your download queue. More on this feature later in this post.</p>
<p>Similar context menu appears when you long tap (hold) somewhere on a page &#8211; but with slightly different options that are available for current page.</p>
<p>Same menu can be invoked also from the bottom sliding menu when clicked on three dots icon.</p>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<hr style="width: 0px;" width="0" />
<h2>Saved Web Pages screen:</h2>
<p>All saved pages are displayed and managed on this screen. You can see a list of your downloaded web pages sorted by date in descending order.</p>
<p>Filter box on top can be used to narrow down a list to some specific pages if you have a lot of them.</p>
<p><a href="http://blog.roboblob.com/wp-content/uploads/2012/05/screenshot1.jpg" rel="lightbox[obfp]"><img class="alignleft size-full wp-image-548" style="margin: 10px;" title="Offline Browser saved web pages screen" src="http://blog.roboblob.com/wp-content/uploads/2012/05/screenshot1.jpg" alt="" width="240" height="400" /></a></p>
<p>On this screen you can long tap on a page in the list to get context menu with options for that specific page like Delete, Delete All and View.</p>
<p>By just clicking on a page you are taken to the browser screen and full content of this page is loaded from the phone storage without the need of internet connection.</p>
<p>Neat right?</p>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<hr style="width: 0px;" width="0" />
<h2> </h2>
<h2>So how do we automate this thing?</h2>
<p>Yes i know, I&#8217;m also lazy. I don&#8217;t like having to go into the mobile app, browsing websites on the phone and saving pages for later viewing or typing long URLs.</p>
<p>So i came up with this solution:</p>
<p>When I&#8217;m at my desktop computer and i see a web page I want to read later on my phone i add it to my Instapaper.com reading list or i bookmark it under special tag in my Delicious.com account.</p>
<p>Then i copy URL of these RSS feeds from Instapaper account or Delicious.com to Offline Browser application settings page as Link Feeds and these feeds will be used as source for new links that i will later download to my phone.</p>
<p>Here is how it looks in the application settings page for the Link Feeds:</p>
<p><a href="http://blog.roboblob.com/wp-content/uploads/2012/05/7.png" rel="lightbox[obfp]"><img class="alignleft size-full wp-image-557" style="margin: 10px; clear: both;" title="Offline Browser Link Feeds Settings" src="http://blog.roboblob.com/wp-content/uploads/2012/05/7.png" alt="" width="240" height="400" /></a></p>
<p> You can switch on/off background retrieval of the links from the feeds and you can set how often synchronization is performed.</p>
<p> Below you can manually add more Link Feeds by typing their URL or pasting it into the text box.</p>
<p> Its important to note here that if you switch on this option then feeds are synced in the background tasks even when your app is not running.</p>
<p> Due to limitations in Windows Phone Background Tasks application does not sync full content of the pages from those URLs but only fetches their URLs and adds them to the download queue.</p>
<p>You can then see those links in the Download Queue page and download them all just by clicking on the Sync button.</p>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<hr style="width: 0px;" width="0" />
<h2> Application tile counter</h2>
<p>When you are using background syncing of Link Feeds, application fetches new URLs in the background and notifies you via Toast notification and via Application Tile counter like this:</p>
<p><a href="http://blog.roboblob.com/wp-content/uploads/2012/05/3.png" rel="lightbox[obfp]"><img class="alignleft size-full wp-image-566" style="margin: 10px; clear: both;" title="Windows Phone Offline Browser Live Tile counter on Home Screen" src="http://blog.roboblob.com/wp-content/uploads/2012/05/3.png" alt="Windows Phone Offline Browser Live Tile counter on Home Screen" width="240" height="400" /></a></p>
<p>Here application has downloaded new links from all the Link Feeds and its showing us that there are 5 new web pages to be downloaded.</p>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<hr style="width: 0px;" width="0" />
<h2> </h2>
<h2>Download Queue</h2>
<p>When we have some pages in the download queue then on application start we are immediately taken to the Download Queue page:</p>
<p><a href="http://blog.roboblob.com/wp-content/uploads/2012/05/screenshot4.jpg" rel="lightbox[obfp]"><img class="alignleft size-full wp-image-567" style="margin: 10px; clear: both;" title="Windows Phone Offline Browser Download Queue page showing urls to download" src="http://blog.roboblob.com/wp-content/uploads/2012/05/screenshot4.jpg" alt="Windows Phone Offline Browser Download Queue page showing urls to download" width="240" height="400" /></a></p>
<p>This can be configured in the settings so that you are not redirected here when there are links in the queue so you can choose whats more logical for you.</p>
<p>Once we click the sync button on the top of the page, application starts downloading all the web pages from the download queue and saves them to phone.</p>
<p>Once they are downloaded you can access them from the Saved Pages screen.</p>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<hr style="width: 0px;" width="0" />
<h2> </h2>
<h2>Browser User Agent settings</h2>
<p>Another feature of the app is that you can choose in Settings the Browser User Agent String to be used when browsing and downloading web pages:</p>
<p><a href="http://blog.roboblob.com/wp-content/uploads/2012/05/screenshot7.jpg" rel="lightbox[obfp]"><img class="alignleft size-full wp-image-568" style="margin: 10px; clear: both;" title="Windows Phone Offline Browser Browser User Agent String Settings" src="http://blog.roboblob.com/wp-content/uploads/2012/05/screenshot7.jpg" alt="Windows Phone Offline Browser Browser User Agent String Settings" width="240" height="400" /></a></p>
<p>You can pick one of the existing browser User Agent Strings like Mobile or Desktop Internet Explorer or IPhone or simply choose Custom and enter or copy/paste your own User Agent of choice.</p>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<hr style="width: 0px;" width="0" />
<h2> </h2>
<h2>Before going to sleep</h2>
<p>So this was just a short introduction on what this handy application is and and what it can do.</p>
<p>If you want to test it go to the marketplace and <a title="Offline Browser in Marketplace" href="http://windowsphone.com/s?appid=e34e28aa-b6bc-48f5-b3f8-62f0dc41757f">download a trial version of Offline Browser</a> (its fully functional trial with ads) and give it a try.</p>
<p>If you really find it useful well you might as well buy it, right?  <img src='http://blog.roboblob.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>In my upcoming blog posts i will explain some of the less visible features like how saving of page scroll position works etc.</p>
<p>Also expect some Windows Phone programming posts since i have a lot of tips and tricks to share so stay tuned and happy offline browsing!</p>
<img src="http://feeds.feedburner.com/~r/roboblob/~4/15IAshQr16k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.roboblob.com/2012/05/26/offline-browser-for-windows-phone-is-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Why I think Windows Phone is superior phone OS?</title>
		<link>http://blog.roboblob.com/2012/01/08/why-i-think-windows-phone-is-superior-phone-os/</link>
		<comments>http://blog.roboblob.com/2012/01/08/why-i-think-windows-phone-is-superior-phone-os/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 11:29:01 +0000</pubDate>
		<dc:creator>roboblob</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Phone]]></category>

		<guid isPermaLink="false">http://blog.roboblob.com/?p=494</guid>
		<description><![CDATA[Let me try to summarize the things i personally love about my new Windows Phone...]]></description>
				<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://blog.roboblob.com/2012/01/08/why-i-think-windows-phone-is-superior-phone-os/", "Why I think Windows Phone is superior phone OS?", "" );
		//--></script></span><h2>Windows Phone? How did that happen?</h2>
<p>Well over the last couple of months i was experimenting with mobile devices a lot because i was kind of tired of the Desktop and the whole HTML5 madness (yes i don&#8217;t like Java Script that much and i certainly don&#8217;t think its the-way-of-the-future, but that&#8217;s subject for another post).</p>
<p>Out of desperation at first i tried Android and got me a <a href="http://www.gsmarena.com/lg_optimus_one_p500-3516.php" target="_blank">LG Optimus One</a> phone. And I must admit that i liked it very much.</p>
<p>Yes, battery lifetime was problem at start, but installing <a href="http://www.cyanogenmod.com/" target="_blank">CyanogenMod</a> custom ROM completely solved that. I even spent some time programming an Android game but that failed miserably because my productivity was close to zero considering all the new things i needed to learn (Java, Open GL).</p>
<p>And all that time <a href="http://papiri.rs/" target="_blank">one good friend</a> was constantly telling me how great his Windows Phone was. I was very skeptical about that since I previously owned Windows Mobile 6.5 phone  and it was complete failure. I even recall at some time in the past promising to my self that i will never buy Windows powered phone again!</p>
<p>But after hearing all the good things about new Microsoft phone OS I eventually decided to give it a try and got me a <a href="http://www.gsmarena.com/samsung_focus-3453.php" target="_blank">Samsung Focus</a> with Windows Phone Mango installed.</p>
<h3>Boy was i pleasantly surprised.</h3>
<p>And lets be honest here: its not that i did not like Android.  Its good and mature mobile OS.<br />
Its (kind of) Open Source and its has significant market share &#8211; not without good reason.</p>
<p>But using Windows Phone after Android was a really pleasent and refreshing experience. And there is no way I&#8217;m going back.</p>
<p><em><span style="text-decoration: underline;">Disclaimer:</span></em><em> before I continue i want to make few things clear: i don&#8217;t work for Microsoft, and i never did and probably never will. Everything i say on this blog is my personal opinion and not of my neighbors or my dog.</em></p>
<h2>So now let me try to summarize the things i</h2>
<h2>personally love about my new Windows Phone:</h2>
<p><strong> </strong></p>
<ul>
<li><strong>Superb UI </strong>- The whole phone User Interface is absolutely AMAZING!  Its very simple and intuitive.<br />
Yet at the same time it manages to stay slick and beautiful with subtle animations and transitions that do not annoy user but enhance the overall UI experience and make it fun and pleasant.<br />
UI team did a great job &#8211; without any compromises. This is huge win for the platform.</li>
</ul>
<ul>
<li><strong>Live Tiles</strong> &#8211; When we speak of the User Experience I must mention the excellent Live Tiles concept.<br />
Live Tiles are actually just animated squares on your home screen  that represent applications or shortcuts for documents, contacts, URLs or any other static/dynamic piece of information that you can pin and arrange on your mobile &#8216;desktop&#8217;.<br />
They are called Live for a good reason &#8211; they often change their content to show additional information &#8211; like number of emails in inbox for email application Live Tile, current temperature for weather app Live Tile etc.<br />
I like this because it works great for the limited screen space of the phone &#8211; each of the tiles can show more info by flipping to display live content as it becomes available/relevant.</li>
</ul>
<ul>
<li><strong>The phone </strong><a href="http://c2.com/cgi/wiki?ItJustWorks" target="_blank"><strong>Just Works</strong></a> &#8211; From the practical everyday usage perspective the OS feels very natural and in 99% of cases works exactly as you think it will.<br />
I have to admit that i never expected this from Microsoft but the whole Windows Phone is so well planed and designed that its never in the way when you are using it. One good example is how built-in music player works with non-standard headphones.<br />
I tried plugging in the headphones from my old Android phone (it’s a different manufacturer) and I was able to control music playback by pressing the hardware button on the headphones, one press for play/pause, double press to skip current track. Yes I know this is minor and expected thing, but  remember i found this out just by trying and expecting that it should work, and it &#8216;just worked&#8217;  even with non-supported headphones.<br />
And when you use the phone you often catch yourself thinking &#8216;Wow this works just as I expected it to work&#8217;. After few moments like that and I was already bought.</li>
</ul>
<ul>
<li><strong>General Email experience</strong> is great! In my opinion its superior when compared to the built in email clients on IPhone or  Android. And I don’t mean just MS Exchange email.<br />
I&#8217;m a long time Google Mail user and i don&#8217;t use Exchange Server at all. So i was little worried how this will work with MS phone &#8211; but without any reason.Gmail works flawlessly out of the box without ANY additional  apps or customizations. I  just added my Google account and it worked. Even the push notifications worked without a single glitch. It also synced my Google Email Contacts and Google Calendar  in expected way, no fuss.</li>
</ul>
<ul>
<li><strong>Built in keyboard is great!</strong> Unlike Android you cannot replace keyboard with 3rd party replacement, but there is really no reason for you to do so any way.<br />
Default keyboard flawlessly supports multiple languages &#8211; I&#8217;m using English and Czech settings and i can enter all the Czech special characters very easily (they appear by long pressing the keys &#8211; as expected).<br />
Actually I&#8217;m deliberately writing this post on the phone using that same keyboard just to prove the point (therefore don’t mind my spelling, please).<br />
<strong>Copy and paste</strong> works very nice and another thing i like is the <strong>caret repositioning</strong> &#8211; just by long pressing the screen and then moving the caret around &#8211; i would love to see this working so nice on Android.</li>
</ul>
<ul>
<li><strong>Multitasking</strong> experience is very nice at least in the Mango Windows Phone version that i have.<br />
Actually there is no real multitasking (if you exclude the occasional background data sync) because only one app is active at the moment. Others are &#8216;<a href="http://msdn.microsoft.com/en-us/library/ff817008(v=vs.92).aspx" target="_blank">tombstoned</a>&#8216; until you activate them.<br />
But there is very nice illusion of multitasking that does the job pretty well.<br />
By long pressing the Back hardware button you get on the screen very cool visual &#8216;Task Manager&#8217; where you can see list of your app screens which you can scroll through and choose which app you want to activate now.<br />
Simply brilliant.<br />
On the other hand Android has true multitasking but list of running apps is hidden in phone settings and not so slick at all.</li>
</ul>
<ul>
<li><strong>Phone and SMS functionality</strong> &#8211; Simple, quick and feature rich yet not in your way when you want to do quick call or SMS somebody. And I could hardly say that for Android or IPhone. Very impressive.</li>
</ul>
<ul>
<li><strong>TextToSpeech and SpeechToText</strong> &#8211; Windows Phone has pretty decent voice recognition and when you use wireless or wired headsets you can set it up so that it reads you your SMS messages and you can reply to them over voice command and then dictate your answer. Have a look at this <a href="http://www.zdnet.com/blog/hardware/windows-phone-75-mango-killer-feature-voice-to-text/14072" target="_blank">Windows Phone voice commanding demo</a> if you want to know more. Yes i know its not <a href="http://www.apple.com/iphone/features/siri.html" target="_blank">Siri </a>and it can be much better but even as it is now is quite usable if you are native English speaker.</li>
</ul>
<ul>
<li><strong>Marketplace</strong> &#8211; Even though there are less apps then for other platforms, there are enough of them and number is growing so time will fix that. But generally speaking Marketplace is already mature and useful.</li>
</ul>
<ul>
<li><strong>Social Networks integration</strong> is flawless. Again without any third party tools.<br />
Facebook, Twitter, LinkedIn you name it. Its all integrated into People hub on the phone, so you can merge Facebook account with your SIM card phone contact to use it as his/hers account picture etc.</li>
</ul>
<ul>
<li>do i need to mention that <strong>phone integrates nicely with desktop MS Office?</strong> OneNote, Word, Excel it works as good as it can get on a mobile device. I don&#8217;t use it too much except for OneNote but i think its huge win for corporate users.</li>
</ul>
<ul>
<li><strong>Built in Music Player and Radio app are great</strong> and i enjoy using them for they simplicity and stability. Not a single crash. Try that on android device and good luck trying!</li>
</ul>
<ul>
<li>One big advantage of Windows Phone for<strong> .NET</strong> software developers especially for <strong>Silverlight</strong> folks is that programming Windows Phone is very familiar experience.  Visual Studio has very good support for phone development and Emulator for Windows Phone is in my personal opinion much better and faster then Android one. (Off course one could say I am biased since I&#8217;m .NET developer but speed is something that is easily measurable).<br />
If you have .NET background you can start app development or XNA game development in no time.<br />
And the Marketplace is not overcrowded. Anyone mentioned word <strong>Opportunity</strong>?</li>
</ul>
<ul>
<li>Another small thing that can be a lifesaver is the <strong>phone boot time</strong>.<br />
My Samsung Focus boots in 20 seconds and its immediately ready to make phone calls or to write SMS.<br />
My Android device was not even close to that and even when it was booted it remained to be slow for some time, probably until Micro SD card is initialized and until all the services are up and running.<br />
Sometimes when you need to make an urgent call this can be really important feature.</li>
</ul>
<ul>
<li>Every Windows Phone has built in<strong> </strong><a href="https://www.windowsphone.com/en-US/find" target="_blank"><strong>Find My Phone</strong></a> feature that allows you (if you enable it) to see on the map where is your phone and to start the Ringing on the phone, Lock it or Erase it (off course it needs to be connected on the network for this to work).<br />
This is useful if you lose your phone, or if it gets stolen. I&#8217;m not sure about IPhone but I know that on Android you need to install third party apps for this so this is another nice benefit of this platform.</li>
</ul>
<ul>
<li><strong>Battery</strong><strong> Saver</strong> &#8211; if enabled phone automatically switches to power saving mode when battery is low (stops background sync for example)  and your phone calls and SMS functionality continues to work until there is juice in the battery. I really like this because after all this is a phone device so my calls are more important then my Facebook updates <img src='http://blog.roboblob.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
<ul>
<li><strong>Lock Screen</strong> on Windows Phone is beautiful. It is following the general minimalistic approach but still manages to show all the relevant information &#8211; calendar items, missed calls, messages, emails etc. If you are playing some music there are small controls there.<br />
All in all very nice without unnecessary bells and whistles.</li>
</ul>
<p>I could continue like this for some times because there are many other nice things that deserve mention.</p>
<h4>But at the same time this is young phone platform so there are also some problems to be addressed.</h4>
<p>The biggest issue I currently see for Windows Phone is that its not open enough for developers. Many OS features are exclusively used only by OS apps and by Vendors apps and everyday developers don’t have APIs to access them. Much has been written on the subject so I wont repeat it here, so read the post <a href="http://www.orktane.com/post/2011/02/11/From-a-Developers-Perspective-10-ways-to-improve-Windows-Phone-7.aspx" target="_blank">10 ways to improve Windows Phone 7</a> if you are interested or <a href="http://www.orktane.com/post/2010/09/26/WP7-Extensibility-Rant.aspx" target="_blank">WP7 Extensibility Rant</a> from same author.</p>
<p>Typical example is that in 3rd party apps you cannot subscribe to some user invoked actions, for example <a href="http://stackoverflow.com/questions/8562005/how-to-subscribe-to-get-sharelinktask-notifications-in-windows-phone-mango" target="_blank">there is no way for user to send url to non system application</a>.</p>
<p>I dont see anyone benefiting from this kinds of limitations.</p>
<p>I really hope that Windows Phone team will address these problems and give developers more power.</p>
<p>There is <a href="http://wpdev.uservoice.com/forums/110705-app-platform" target="_blank">WPDev User Voice Feedback site</a> where all the requests from the developer community are listed &#8211; so there is hope this will change soon.</p>
<p>Another thing I don’t like is that for some settings there is no quick way of access.<br />
For example WiFi or Flight Mode. In order to manipulate them you need to go to System Settings and choose menu item  and then switch them on or off. Instead of this hassle I would like to have quick toggle button somewhere on the phone desktop.</p>
<p>Again this is something that would be solved if developers could have access to those settings to programmatically manipulate them.</p>
<p>I guess Microsoft do not want to open the Pandora&#8217;s Box by giving  too much power to 3rd party apps, but I think they over did it in this case.</p>
<p>Right balance between opennes and system security on Windows Phone needs yet to be determined.</p>
<p>I would also love to see support for more languages for Text To Speech and Voice Recognition. Im not sure abut Microsoft plans but this would be a killer feature since i think voice is the way to go when it comes to the future of mobile platforms.</p>
<h4>Wow this was longer post that I originally intended it to be!</h4>
<p>I hope I was able to explain why I personally choose Windows Phone over other modern phone platforms.</p>
<p>Then again, this is all my personal experience and your mileage may vary.</p>
<p>It all depends on what you expect from your phone:</p>
<ul>
<li>If you want to pay for Brand, then simply buy IPhone.</li>
<li>If you want phone that does everything you want and that is completely customizable yes often fails because its complex and bloated with unstable apps &#8211; get Android.</li>
<li>if you just wont cool phone that dont stand in your way but does all things you really could need from mobile device &#8211; i recommend Windows Phone</li>
</ul>
<p>I don’t really expect my phone to be Swiss army knife capable of EVERYTHING but failing to do anything efficiently.</p>
<p>I like minimalistic approach and simplicity so probably this is why I like Windows Phone so much.</p>
<p>But the war of the platforms is still on so don’t be surprised if tomorrow I choose another <img src='http://blog.roboblob.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Those were my 2 cents on the subject, let me know what&#8217;s your experience and what is your best mobile OS out there, and most importantly: WHY?</p>
<img src="http://feeds.feedburner.com/~r/roboblob/~4/0EJqtIAvzKc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.roboblob.com/2012/01/08/why-i-think-windows-phone-is-superior-phone-os/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lighthouse – Silverlight Unit Test Runner Project released</title>
		<link>http://blog.roboblob.com/2011/03/22/lighthouse_silverlight_unit_test_runner_project_released/</link>
		<comments>http://blog.roboblob.com/2011/03/22/lighthouse_silverlight_unit_test_runner_project_released/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 23:27:45 +0000</pubDate>
		<dc:creator>roboblob</dc:creator>
				<category><![CDATA[Lighthouse]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[UnitTest]]></category>
		<category><![CDATA[UnitTesting]]></category>

		<guid isPermaLink="false">http://blog.roboblob.com/?p=479</guid>
		<description><![CDATA[Unit Testing in Silverlight? But you need Web Browser to do that!
No you do not! Ok maybe you do. But not in a direct way. I will clarify that later. Lets first go back in time to the root of the story:
Since the initial release of Silverlight i was really annoyed by the fact that Unit Testing had  [...]]]></description>
				<content:encoded><![CDATA[<span class="read_later"><script type="text/javascript"><!--
			instapaper_embed( "http://blog.roboblob.com/2011/03/22/lighthouse_silverlight_unit_test_runner_project_released/", "Lighthouse &#8211; Silverlight Unit Test Runner Project released", "" );
		//--></script></span><h2>Unit Testing in Silverlight? But you need Web Browser to do that!</h2>
<p>No you do not! Ok maybe you do. But not in a direct way. I will clarify that later. Lets first go back in time to the root of the story:</p>
<p>Since the initial release of Silverlight i was really annoyed by the fact that Unit Testing had very slim support.</p>
<p>Even later <a href="http://archive.msdn.microsoft.com/silverlightut" target="_blank">when Silverlight Unit Testing Framework</a> was introduced by Microsoft things became little better but still it was far from good.</p>
<p>You could create Unit Tests, but you had to start your Visual Studio in order to run them &#8211; eventually looking at the results of tests in your favorite Web Browser.</p>
<p>That ruled out one of the most important facets of <strong>T</strong>est <strong>D</strong>riven <strong>D</strong>evelopment &#8211; running your Unit Test on Continuous Integration server, so that you can easily see when any of your Unit Tests are broken &#8211; in other words treating your Unit Tests equally as all your code, like you should.</p>
<p>Not to mention that there was no way to run Unit Tests from Reshaper! (oh boy don&#8217;t even let me get started on that one).</p>
<h2>Can feeling of anger be a motivation for good deeds?</h2>
<p>Very likely. I started by investigating what open source projects were available to fill these Silverlight TDD gaps.</p>
<p>And i did found few of them. But they were either too complex or simply did not work properly and failed to run tests from one reason or the other.</p>
<p>This is how i decided to create project <strong>Lighthouse</strong> &#8211; probably in same way how many other open source projects are born: <strong>to scratch an itch</strong> of single developer, for the benefit of the community <img src='http://blog.roboblob.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>What is it for? What&#8217;s the Roadmap?</h2>
<p><a href="http://lighthouse.codeplex.com/" target="_blank">Lighthouse</a> is envisioned as project that will host multiple tools that will allow Silverlight developers to do Test Driven Development much easier then before.<br />
First tool in this project <a href="http://lighthouse.codeplex.com/releases/view/62936" target="_blank">Silverlight Command Line Unit Test Runner</a> has just been released on Codeplex website.</p>
<p>Lighthouse Command Line Unit Test Runner is console application that runs given <a href="http://archive.msdn.microsoft.com/silverlightut" target="_blank">Silverlight Unit Testing Framework</a> Unit Tests and collects their results and saves them in known ﻿<a href="http://www.nunit.org/wiki/doku.php?id=dev:specs:xml_formats&amp;s[]=xml" target="_blank">NUnit XML Unit Tests results file format</a> on your hard-drive.</p>
<h2>What can i expect?</h2>
<p>The rule of the thumb goes like this:</p>
<p><strong>YOUR SILVERLIGHT UNIT TESTS SHOULD BEHAVE EXACTLY THE SAME WHEN YOU RUN THEM WITH LIGHTHOUSE AS IF YOU ARE RUNNING THEM FROM VISUAL STUDIO OR WEB BROWSER.</strong></p>
<p>In other words: If they failed in browser, they will fail when you run them via Lighthouse in completely same way (same timing, same exception etc) &#8211; and vice versa.</p>
<p>You can use Lighthouse to run tests in XAP packaged application or you can use it to run tests directly specifying your Silverlight DLL&#8217;s &#8211; it is very flexible.</p>
<p>Currently Lighthouse saves results in NUnit XML Unit Tests results file format so that means<strong> you can use it to run your Unit Tests in ANY Continuous Integration server</strong> that supports this format &#8211; <a href="http://sourceforge.net/projects/ccnet/" target="_blank">CCNet</a>, <a href="http://www.jetbrains.com/teamcity/" target="_blank">Team City</a> you name it.</p>
<p>In future we will maybe add more output XML formats, but for start this should suffice.</p>
<p>Lighthouse Silverlight Command Line Unit Tests runner supports variety of command line switches so you can tweak it to work how you need it.</p>
<p>You can specify Tag Filter to run only certain test cases.</p>
<p>You can specify timeouts, output log file, output directory etc.</p>
<p>Make sure you visit the <a href="http://lighthouse.codeplex.com/wikipage?title=Lighthouse_Command_Line_Runner_Parameters_Documentation" target="_self">Lighthouse Command Line Test Runner Documentation</a> page to get familiar with all the options.</p>
<p>In the future we are planning to develop Resharper plugin to run Silverlight Unit Tests, but you will here more on that when its ready.</p>
<h2>And how does all this work?</h2>
<p>Its much simpler to explain then it was to make it work:</p>
<p>In its essence, Lighthouse analyzes your XAP/Assemblies and modifies them in a way so that it can control the Unit Test execution. It then fires up a web browser instance in the background and start this modified Silverlight application and collects the results of all Unit Tests. Results are saved in XML file and everyone go home and live happily ever after.</p>
<h2>What now?</h2>
<p>Until future releases I&#8217;m asking all interested Silverlight developers to use Lighthouse and <a href="http://lighthouse.codeplex.com/workitem/list/basic" target="_blank">send us feedback</a> or even join the <a href="http://lighthouse.codeplex.com/team/view" target="_blank">Lighthouse team</a> to make it better.</p>
<p>For the end check out this short video where Lighthouse Command Line Runner executes Silverlight Unit Tests from <a href="http://sterling.codeplex.com/" target="_blank">Sterling</a> project:</p>
<p><iframe width="620" height="465" src="http://www.youtube.com/embed/MhBarClpvp8?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p>Stay tuned&#8230;</p>
<img src="http://feeds.feedburner.com/~r/roboblob/~4/y8EnHaWG3WI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.roboblob.com/2011/03/22/lighthouse_silverlight_unit_test_runner_project_released/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
