<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>Windows Mobile Development</title>
  <link rel="alternate" type="text/html" href="http://blog.wmdev.net/" />
  <link rel="self" href="http://blog.wmdev.net/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2008-09-10T05:50:35.70625-04:00</updated>
  <author>
    <name>Christian Forsberg &amp; Andreas Sjöström</name>
  </author>
  <subtitle>Windows Mobile, Compact Framework, development, and life...</subtitle>
  <id>http://blog.wmdev.net/</id>
  <generator uri="http://www.dasblog.net" version="2.0.7180.0">DasBlog</generator>
  <entry>
    <title>Xperia X1 in October</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/09/10/XperiaX1InOctober.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,e1c2d67c-7643-4a3e-a8ed-9c3c7b2ef8c1.aspx</id>
    <published>2008-09-10T05:50:35.70625-04:00</published>
    <updated>2008-09-10T05:50:35.70625-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <category term="Windows Mobile" label="Windows Mobile" scheme="http://blog.wmdev.net/CategoryView,category,Windows%2BMobile.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Sony Ericsson <a href="http://www.sonyericsson.com/cws/corporate/press/pressreleases/pressreleasedetails/johnnyxfinal-20080910">announces
today</a> that the Windows Mobile-phone Xperia X1 is launched on September the 30<sup>th</sup>.
It will be available in stores on October the 10<sup>th</sup> Aaccording to It24. 
</p>
        <p>
The company's marketing is focused around Johnny X: <em>"Johnny X is about a young
man with amnesia desperately piecing together his identity. The webisodic thriller
comprises of nine episodes, created to demonstrate the rich, immersive and experiential
elements of the Xperia™ X1. "</em></p>
        <p>
Check it out here: <a href="http://www.whoisjohnny-x.com">www.whoisjohnny-x.com</a>!
</p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=e1c2d67c-7643-4a3e-a8ed-9c3c7b2ef8c1" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Back in business</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/08/04/BackInBusiness.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,9ea2fa02-4520-4d15-8d51-f9b252d6685f.aspx</id>
    <published>2008-08-04T03:39:10.835-04:00</published>
    <updated>2008-08-04T03:39:10.835-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <category term="Windows Mobile" label="Windows Mobile" scheme="http://blog.wmdev.net/CategoryView,category,Windows%2BMobile.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
After four weeks of relaxing vacation, I am now back in business. Events around the
iPhone have dominated the mobility market the last four weeks. 
</p>
        <p>
The most interesting aspect of what's going on is how Apple has managed to cut the
operator from the device upgrade och application distribution processes. Microsoft
entered the market a few years ago and let the mobile operators define their own processes.
This has resulted in a broken experience for all Windows Mobile users. Apple has shown
that it is possible to take responsibility of an end-to-end experience. 
</p>
        <p>
I wonder if Microsoft will stick with its strategy and seek process cooperation with
operators or if the company will try to follow Apple's lead.
</p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=9ea2fa02-4520-4d15-8d51-f9b252d6685f" />
      </div>
    </content>
  </entry>
  <entry>
    <title>A New Mobile N-tier Architecture (part 10)</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/05/28/ANewMobileNtierArchitecturePart10.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,a2b0e7e0-317f-4906-ac0f-8db31c267197.aspx</id>
    <published>2008-05-28T02:31:06.046-04:00</published>
    <updated>2008-05-28T23:41:30.702375-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <category term="Architecture" label="Architecture" scheme="http://blog.wmdev.net/CategoryView,category,Architecture.aspx" />
    <category term="Business" label="Business" scheme="http://blog.wmdev.net/CategoryView,category,Business.aspx" />
    <category term="Chris" label="Chris" scheme="http://blog.wmdev.net/CategoryView,category,Chris.aspx" />
    <category term="Compact Framework" label="Compact Framework" scheme="http://blog.wmdev.net/CategoryView,category,Compact%2BFramework.aspx" />
    <category term="Windows Mobile" label="Windows Mobile" scheme="http://blog.wmdev.net/CategoryView,category,Windows%2BMobile.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <img height="220" alt="blueprintui" src="http://blog.wmdev.net/content/binary/WindowsLiveWriter/ANewMobileNtierArchitecturepart10_27AA/blueprintui_thumb.png" width="176" align="right" border="1" />This
is the final post in this series, and for a complete reference, here are the previous
parts:
</p>
        <ul>
          <li>
            <a href="http://blog.wmdev.net/2008/03/28/ANewMobileNtierArchitecturePart1.aspx">Part
1</a> was a general introduction 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/04/ANewMobileNtierArchitecturePart2.aspx">Part
2</a> talked about the changes in the lower tiers (logic + data, LINQ2SQL) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/11/ANewMobileNtierArchitecturePart3.aspx">Part
3</a> discussed the changes in communication (WCF) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/18/ANewMobileNtierArchitecturePart4.aspx">Part
4</a> covered important stuff in the user interface (MVC) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/25/ANewMobileNtierArchitecturePart5.aspx">Part
5</a> summarized the theory and outlined the new architecture 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/05/02/ANewMobileNtierArchitecturePart6.aspx">Part
6</a> started the walkthrough of the architecture code by looking at the business
domain 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/05/09/ANewMobileNtierArchitecturePart7.aspx">Part
7</a> continued the code walkthrough with a look at the service (WCF) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/05/16/ANewMobileNtierArchitecturePart8.aspx">Part
8</a> covered the consumption of the service with .NET CF 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/05/23/ANewMobileNtierArchitecturePart9.aspx">Part
9</a> showed the implementation of the user interface (MVC)</li>
        </ul>
        <p>
The implemented architecture is published on <a href="http://www.codeplex.com/" target="_blank">CodePlex</a> in
a project called <a href="http://www.codeplex.com/wmarch/" target="_blank">Windows
Mobile Architecture Blueprint</a>, and this means that you can access the full source
code as well as discuss it, come with suggested improvements, etc.
</p>
        <p>
On the upper right you see the <a href="http://www.microsoft.com/design/" target="_blank">UX</a> of
the sample client included in the architecture blueprint, and the functionality is
that the combo box is filled with the categories when the application starts. Then,
when a category is selected, the product names are shown in the text box below.
</p>
        <p>
Even if this series is complete, we will continue to build further on this architecture
blueprint, and any suggestions on things to add are most welcome. Any other feedback,
for that matter, is also welcome!
</p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=a2b0e7e0-317f-4906-ac0f-8db31c267197" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Windows Mobile Awareness</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/05/26/WindowsMobileAwareness.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,717fec86-1e8b-4cd0-8847-b7d2ba9b1c49.aspx</id>
    <published>2008-05-26T04:14:47.803346-04:00</published>
    <updated>2008-05-26T04:14:47.803346-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <category term="Windows Mobile" label="Windows Mobile" scheme="http://blog.wmdev.net/CategoryView,category,Windows%2BMobile.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
It was not easy trying to spot a Windows Mobile-phone on a public spot a couple of
years ago. Not so anymore. When I'm out travelling I see Windows Mobile-phones more
and more often, both among business users and consumers. The latest issue of the magazine
"<a href="http://m3.idg.se/">M3 Digital World</a>" includes a test of eight GPS enabled
mobile phones. Five of the eight phones are Windows Mobile-phones. 
</p>
        <p>
The reviewer gives the E-TENs Glofiish X800 a thumbs up! Check out <a href="http://www.engadget.com/2007/03/15/e-tens-glofiish-x800-everything-but-the-qwerty/">engagdet's
review of the unit here…</a></p>
        <p>
We'll see more and more Windows Mobile-phones out on the streets. 
</p>
        <p>
          <img src="http://blog.wmdev.net/content/binary/052608_0814_WindowsMobi1.png" alt="" />
          <br />
          <span style="font-size:10pt">Image: engadget.com</span>
        </p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=717fec86-1e8b-4cd0-8847-b7d2ba9b1c49" />
      </div>
    </content>
  </entry>
  <entry>
    <title>A New Mobile N-tier Architecture (part 9)</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/05/23/ANewMobileNtierArchitecturePart9.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,e5a7cede-a773-498d-a591-d53c7881db6c.aspx</id>
    <published>2008-05-23T06:28:58-04:00</published>
    <updated>2008-05-28T23:41:07.171125-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <category term="Architecture" label="Architecture" scheme="http://blog.wmdev.net/CategoryView,category,Architecture.aspx" />
    <category term="Business" label="Business" scheme="http://blog.wmdev.net/CategoryView,category,Business.aspx" />
    <category term="Chris" label="Chris" scheme="http://blog.wmdev.net/CategoryView,category,Chris.aspx" />
    <category term="Compact Framework" label="Compact Framework" scheme="http://blog.wmdev.net/CategoryView,category,Compact%2BFramework.aspx" />
    <category term="Windows Mobile" label="Windows Mobile" scheme="http://blog.wmdev.net/CategoryView,category,Windows%2BMobile.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
WeI will continue the more practical part of this series by showing how the new mobile
architecture looks in code, and if you want some background, please see the previous
parts:
</p>
        <ul>
          <li>
            <a href="http://blog.wmdev.net/2008/03/28/ANewMobileNtierArchitecturePart1.aspx">Part
1</a> was a general introduction 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/04/ANewMobileNtierArchitecturePart2.aspx">Part
2</a> talked about the changes in the lower tiers (logic + data, LINQ2SQL) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/11/ANewMobileNtierArchitecturePart3.aspx">Part
3</a> discussed the changes in communication (WCF) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/18/ANewMobileNtierArchitecturePart4.aspx">Part
4</a> covered important stuff in the user interface (MVC) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/25/ANewMobileNtierArchitecturePart5.aspx">Part
5</a> summarized the theory and outlined the new architecture 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/05/02/ANewMobileNtierArchitecturePart6.aspx">Part
6</a> started the walkthrough of the architecture code by looking at the business
domain 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/05/09/ANewMobileNtierArchitecturePart7.aspx">Part
7</a> continued the code walkthrough with a look at the service (WCF) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/05/16/ANewMobileNtierArchitecturePart8.aspx">Part
8</a> covered the consumption of the service with .NET CF</li>
        </ul>
        <p>
The implemented architecture is published on <a href="http://www.codeplex.com/" target="_blank">CodePlex</a> in
a project called <a href="http://www.codeplex.com/wmarch/" target="_blank">Windows
Mobile Architecture Blueprint</a>, and this means that you can access the full source
code as well as discuss it, come with suggested improvements, etc. As I walk you through
the creation of the architecture, we suggest you keep the source code handy to check
out more details.
</p>
        <p>
It's time to look at how we can implement the <a href="http://en.wikipedia.org/wiki/Model-view-controller" target="_blank">MVC</a> pattern
in the Windows Mobile client project that we created in the previous part of this
series. As we've touched on before in this series, we have built this part of the
architecture on a very simple and straightforward implementation by Alex Yakhnin,
that he published as a small blog series last fall (see <a href="http://blogs.msdn.com/priozersk/archive/2007/08/06/implementing-mvc-pattern-in-net-cf-applications-part-1.aspx" target="_blank">part
1</a> and <a href="http://blogs.msdn.com/priozersk/archive/2007/08/07/implementing-mvc-pattern-in-net-cf-applications-part-2.aspx" target="_blank">part
2</a>).
</p>
        <p>
As Alex, I started with the core interfaces...
</p>
        <div style="font-size: 10pt; font-family: monospace; background-color: white">
          <span style="color: blue">interface</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">IView<br /></span>
          <span style="color: black">{<br />
    </span>
          <span style="color: blue">void</span>
          <span style="color: black"> Show();<br />
    </span>
          <span style="color: blue">void</span>
          <span style="color: black"> Hide();<br />
    </span>
          <span style="color: blue">void</span>
          <span style="color: black"> Close();<br />
    </span>
          <span style="color: blue">string</span>
          <span style="color: black"> Text
{ </span>
          <span style="color: blue">get</span>
          <span style="color: black">; </span>
          <span style="color: blue">set</span>
          <span style="color: black">;
}<br />
}</span>
        </div>
        <div style="font-size: 10pt; font-family: monospace; background-color: white">
          <span style="color: blue">interface</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">IController<br /></span>
          <span style="color: black">{<br />
    </span>
          <span style="color: #2b91af">IView</span>
          <span style="color: black"> View
{ </span>
          <span style="color: blue">get</span>
          <span style="color: black">; </span>
          <span style="color: blue">set</span>
          <span style="color: black">;
}<br />
}</span>
        </div>
        <p>
...and then the interface for the main view (form)...
</p>
        <div style="font-size: 10pt; font-family: monospace; background-color: white">
          <span style="color: blue">interface</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">IMainView</span>
          <span style="color: black"> : </span>
          <span style="color: #2b91af">IView<br /></span>
          <span style="color: black">{<br />
    </span>
          <span style="color: #2b91af">Category</span>
          <span style="color: black"> SelectedCategory
{ </span>
          <span style="color: blue">get</span>
          <span style="color: black">; }<br /><br />
    </span>
          <span style="color: blue">void</span>
          <span style="color: black"> SetCategories(</span>
          <span style="color: #2b91af">Category</span>
          <span style="color: black">[]
categories);<br />
    </span>
          <span style="color: blue">void</span>
          <span style="color: black"> SetProducts(</span>
          <span style="color: blue">string</span>
          <span style="color: black"> products);<br /><br />
    </span>
          <span style="color: blue">event</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">EventHandler</span>
          <span style="color: black"> Done;<br />
    </span>
          <span style="color: blue">event</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">EventHandler</span>
          <span style="color: black"> CategorySelected;<br />
}</span>
        </div>
        <p>
...which already tells us what the main form can do. It allows us to set a number
of categories (to choose from, SetCategories) and it will notify when a category is
selected (CategorySelected). It will also make that selected category available through
a public property (SelectedCategory) and allow us to set the products for a (the selected)
category (SetProducts). Finally, it will notify when the user is done with it (Done).
</p>
        <p>
The implementation of the controller for the main form looks like this...
</p>
        <div style="font-size: 10pt; font-family: monospace; background-color: white">
          <span style="color: blue">class</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">MainController</span>
          <span style="color: black"> : </span>
          <span style="color: #2b91af">IController<br /></span>
          <span style="color: black">{<br />
    </span>
          <span style="color: blue">private</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">IMainView</span>
          <span style="color: black"> view;<br />
    </span>
          <span style="color: blue">private</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">ServiceClient</span>
          <span style="color: black"> service;<br /><br />
    </span>
          <span style="color: blue">public</span>
          <span style="color: black"> MainController(</span>
          <span style="color: #2b91af">IMainView</span>
          <span style="color: black"> view)<br />
    {<br />
        View = view;<br /><br />
        </span>
          <span style="color: #2b91af">ServiceClient</span>
          <span style="color: black">.EndpointAddress
= </span>
          <span style="color: blue">new</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">EndpointAddress</span>
          <span style="color: black">(</span>
          <span style="color: #a31515">"http://192.168.0.100:5610/Service.svc/basic"</span>
          <span style="color: black">);<br />
        service = </span>
          <span style="color: blue">new</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">ServiceClient</span>
          <span style="color: black">();<br /><br />
        </span>
          <span style="color: #2b91af">Category</span>
          <span style="color: black">[]
categories = service.GetCategories();<br />
        view.SetCategories(categories);<br />
    }<br /><br />
    </span>
          <span style="color: blue">private</span>
          <span style="color: black">
          </span>
          <span style="color: blue">void</span>
          <span style="color: black"> attachView(</span>
          <span style="color: #2b91af">IMainView</span>
          <span style="color: black"> view)<br />
    {<br />
        </span>
          <span style="color: blue">this</span>
          <span style="color: black">.view
= view;<br />
        view.CategorySelected += </span>
          <span style="color: blue">new</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">EventHandler</span>
          <span style="color: black">(view_CategorySelected);<br />
        view.Done += </span>
          <span style="color: blue">new</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">EventHandler</span>
          <span style="color: black">(view_Done);<br />
    }<br /><br />
    </span>
          <span style="color: blue">void</span>
          <span style="color: black"> view_CategorySelected(</span>
          <span style="color: blue">object</span>
          <span style="color: black"> sender, </span>
          <span style="color: #2b91af">EventArgs</span>
          <span style="color: black"> e)<br />
    {<br /></span>
          <span style="color: black">        </span>
          <span style="color: #2b91af">Category</span>
          <span style="color: black"> category
= view.SelectedCategory;<br />
        </span>
          <span style="color: blue">string</span>
          <span style="color: black"> s
= </span>
          <span style="color: blue">string</span>
          <span style="color: black">.Empty;<br />
        </span>
          <span style="color: blue">foreach</span>
          <span style="color: black">(</span>
          <span style="color: #2b91af">Product</span>
          <span style="color: black"> product </span>
          <span style="color: blue">in</span>
          <span style="color: black"> category.Products)<br />
            s += product.ProductName
+ </span>
          <span style="color: #a31515">"\r\n"</span>
          <span style="color: black">;<br />
        view.SetProducts(s);<br />
    }<br /><br />
    </span>
          <span style="color: blue">void</span>
          <span style="color: black"> view_Done(</span>
          <span style="color: blue">object</span>
          <span style="color: black"> sender, </span>
          <span style="color: #2b91af">EventArgs</span>
          <span style="color: black"> e)<br />
    {<br /></span>
          <span style="color: black">        </span>
          <span style="color: #2b91af">Application</span>
          <span style="color: black">.Exit();<br />
    }<br /><br /></span>
          <span style="color: blue">    #region</span>
          <span style="color: black"> IController
Members<br />
    </span>
          <span style="color: blue">public</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">IView</span>
          <span style="color: black"> View<br />
    {<br />
        </span>
          <span style="color: blue">get</span>
          <span style="color: black"> { </span>
          <span style="color: blue">return</span>
          <span style="color: black"> view;
}<br />
        </span>
          <span style="color: blue">set</span>
          <span style="color: black"> {
attachView(</span>
          <span style="color: blue">value</span>
          <span style="color: black">
          </span>
          <span style="color: blue">as</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">IMainView</span>
          <span style="color: black">);
}<br />
    }<br /></span>
          <span style="color: blue">    #endregion<br /></span>
          <span style="color: black">}</span>
        </div>
        <p>
..and upon creation, the controller saves its view, and set up the event handlers
to capture event from the view. Then it make the first call to the service to get
the category list which is sent to the view. When a category is selected, a string
is created (I know, in a real solution it would be a StringBuilder, but this code
is simpler to read) and passed to the view.
</p>
        <p>
The implementation of the main view (form) looks like this...
</p>
        <div style="font-size: 10pt; font-family: monospace; background-color: white">
          <span style="color: blue">public</span>
          <span style="color: black">
          </span>
          <span style="color: blue">partial</span>
          <span style="color: black">
          </span>
          <span style="color: blue">class</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">MainForm</span>
          <span style="color: black"> : </span>
          <span style="color: #2b91af">Form</span>
          <span style="color: black">, </span>
          <span style="color: #2b91af">IMainView<br /></span>
          <span style="color: black">{<br /></span>
          <span style="color: blue">    public</span>
          <span style="color: black"> MainForm()<br />
    {<br />
        InitializeComponent();<br />
    }<br /></span>
          <span style="color: blue">
            <br />
          </span>
          <span style="color: black">    </span>
          <span style="color: blue">public</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">Category</span>
          <span style="color: black"> SelectedCategory<br />
    {<br />
        </span>
          <span style="color: blue">get</span>
          <span style="color: black"> { </span>
          <span style="color: blue">return</span>
          <span style="color: black"> categoryComboBox.SelectedItem </span>
          <span style="color: blue">as</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">Category</span>
          <span style="color: black">;
}<br />
    }<br /></span>
          <span style="color: blue">
            <br />
          </span>
          <span style="color: black">    </span>
          <span style="color: blue">public</span>
          <span style="color: black">
          </span>
          <span style="color: blue">void</span>
          <span style="color: black"> SetCategories(</span>
          <span style="color: #2b91af">Category</span>
          <span style="color: black">[]
categories)<br />
    {<br />
        </span>
          <span style="color: blue">foreach</span>
          <span style="color: black">(</span>
          <span style="color: #2b91af">Category</span>
          <span style="color: black"> category </span>
          <span style="color: blue">in</span>
          <span style="color: black"> categories)<br />
            categoryComboBox.Items.Add(category);<br />
    }<br /><br />
    </span>
          <span style="color: blue">public</span>
          <span style="color: black">
          </span>
          <span style="color: blue">void</span>
          <span style="color: black"> SetProducts(</span>
          <span style="color: blue">string</span>
          <span style="color: black"> products)<br />
    {<br />
        productsTextBox.Text = products;<br />
    }<br /></span>
          <span style="color: blue">
            <br />
          </span>
          <span style="color: black">    </span>
          <span style="color: blue">public</span>
          <span style="color: black">
          </span>
          <span style="color: blue">event</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">EventHandler</span>
          <span style="color: black"> CategorySelected;<br />
    </span>
          <span style="color: blue">private</span>
          <span style="color: black">
          </span>
          <span style="color: blue">void</span>
          <span style="color: black"> categoryComboBox_SelectedIndexChanged(</span>
          <span style="color: blue">object</span>
          <span style="color: black"> sender, </span>
          <span style="color: #2b91af">EventArgs</span>
          <span style="color: black"> e)<br />
    {<br />
        </span>
          <span style="color: blue">if</span>
          <span style="color: black">(CategorySelected
!= </span>
          <span style="color: blue">null</span>
          <span style="color: black">)<br />
            CategorySelected(</span>
          <span style="color: blue">this</span>
          <span style="color: black">, </span>
          <span style="color: blue">null</span>
          <span style="color: black">);<br />
    }<br /><br />
    </span>
          <span style="color: blue">public</span>
          <span style="color: black">
          </span>
          <span style="color: blue">event</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">EventHandler</span>
          <span style="color: black"> Done;<br />
    </span>
          <span style="color: blue">private</span>
          <span style="color: black">
          </span>
          <span style="color: blue">void</span>
          <span style="color: black"> doneMenuItem_Click(</span>
          <span style="color: blue">object</span>
          <span style="color: black"> sender, </span>
          <span style="color: #2b91af">EventArgs</span>
          <span style="color: black"> e)<br />
    {<br />
        </span>
          <span style="color: blue">if</span>
          <span style="color: black">(Done
!= </span>
          <span style="color: blue">null</span>
          <span style="color: black">)<br />
            Done(</span>
          <span style="color: blue">this</span>
          <span style="color: black">, </span>
          <span style="color: blue">null</span>
          <span style="color: black">);<br />
    }<br /></span>
          <span style="color: black">}<br /></span>
        </div>
        <p>
...and here we see that the categories are loaded in a combo box which is used to
determine the currently selected category, and also to raise the event when a category
is selected. The products string is simply put into a text box, and a menu option
is used to offer the user to exit.
</p>
        <p>
To manage (can cache) the various controllers and views, we use the following singleton
class... 
</p>
        <div style="font-size: 10pt; font-family: monospace; background-color: white">
          <span style="color: blue">class</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">ApplicationManager<br /></span>
          <span style="color: black">{<br />
    </span>
          <span style="color: blue">public</span>
          <span style="color: black">
          </span>
          <span style="color: blue">static</span>
          <span style="color: black">
          </span>
          <span style="color: blue">readonly</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">ApplicationManager</span>
          <span style="color: black"> Instance
= </span>
          <span style="color: blue">new</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">ApplicationManager</span>
          <span style="color: black">();<br />
    </span>
          <span style="color: blue">private</span>
          <span style="color: black"> ApplicationManager()
{ }<br /><br />
    </span>
          <span style="color: blue">private</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">Dictionary</span>
          <span style="color: black">&lt;</span>
          <span style="color: blue">string</span>
          <span style="color: black">, </span>
          <span style="color: #2b91af">IController</span>
          <span style="color: black">&gt;
controllersCache;<br /><br />
    </span>
          <span style="color: blue">public</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">MainForm</span>
          <span style="color: black"> GetMainForm()<br />
    {<br />
        </span>
          <span style="color: blue">if</span>
          <span style="color: black">(!controllersCache.ContainsKey(</span>
          <span style="color: #a31515">"Main"</span>
          <span style="color: black">))<br />
            controllersCache.Add(</span>
          <span style="color: #a31515">"Main"</span>
          <span style="color: black">, </span>
          <span style="color: blue">new</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">MainController</span>
          <span style="color: black">(</span>
          <span style="color: blue">new</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">MainForm</span>
          <span style="color: black">()));<br />
        </span>
          <span style="color: blue">return</span>
          <span style="color: black"> controllersCache[</span>
          <span style="color: #a31515">"Main"</span>
          <span style="color: black">].View </span>
          <span style="color: blue">as</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">MainForm</span>
          <span style="color: black">;<br />
    }<br />
}</span>
        </div>
        <p>
...and the application is kicked off like this...
</p>
        <div style="font-size: 10pt; font-family: monospace; background-color: white">[<span style="color: #2b91af">MTAThread</span><span style="color: black">]<br /></span><span style="color: blue">static</span><span style="color: black"></span><span style="color: blue">void</span><span style="color: black"> Main()<br />
{<br />
    </span><span style="color: #2b91af">Application</span><span style="color: black">.Run(</span><span style="color: #2b91af">ApplicationManager</span><span style="color: black">.Instance.GetMainForm());<br />
}</span></div>
        <p>
...which concludes the walkthrough of the basic architectore! In the next post, we
will summarize this series of blog posts on the architecture blueprint implementation.
</p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=e5a7cede-a773-498d-a591-d53c7881db6c" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Implementing Transparancy</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/05/22/ImplementingTransparancy.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,e2b81ad2-6e0e-471b-9bdb-a96f58986267.aspx</id>
    <published>2008-05-22T03:27:07.955-04:00</published>
    <updated>2008-05-22T03:27:07.955-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
This article came in very handy in our project!
</p>
        <p>
          <em>"Creating controls for .NET Compact Framework–based applications—which include
transparency, gradients, and three-dimensional glass-like appearance—is well within
reach today, using existing Microsoft Windows Mobile development tools. This article
will demonstrate how to achieve transparency, gradients, and glass effects by extending
existing .NET Compact Framework controls and leveraging some powerful native graphics
features available in the Windows Mobile operating system."</em>
        </p>
        <p>
          <a href="http://msdn.microsoft.com/en-us/library/cc531311.aspx">Read it here...</a>
        </p>
        <p>
          <img alt="" src="http://msdn.microsoft.com/en-us/library/Cc531311.619af29c-ece4-441e-b522-f888be5d7913(en-us,MSDN.10).png" />
        </p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=e2b81ad2-6e0e-471b-9bdb-a96f58986267" />
      </div>
    </content>
  </entry>
  <entry>
    <title>The butterfly</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/05/21/TheButterfly.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,bf5f1293-56c4-451d-8424-d069e1b7469a.aspx</id>
    <published>2008-05-21T06:04:50.939375-04:00</published>
    <updated>2008-05-21T06:04:50.939375-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <category term="Windows Mobile" label="Windows Mobile" scheme="http://blog.wmdev.net/CategoryView,category,Windows%2BMobile.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
My latest column was published in Computer Sweden today. You can <a href="http://computersweden.idg.se/2.2683/1.162688">read
it here…</a></p>
        <p>
In the column I write about a field trip with some biologists. We had designed a Windows
Mobile-application that they used when stock taking meadows and pasture lands. During
the field trip I analyzed how the solution worked in reality… and I had the privilige
of learning a lot about the landscape. 
</p>
        <p>
The most inspiring thing was when one of the biologists "read" the landscape and could
foretell what butterfly we would likely to find at a particular place. He was right.
See my pictures from the event below! 
</p>
        <p>
When I look into the IT-landscape today I see mobile device management (Sybase OneBridge,
Microsoft Mobile Device Manager and The Institution), Web 2.0 (Sharepoint, Confluence,
Incentive from Mindroute), and development tools that melt together with designer
tools (Flash, Silverlight). 
</p>
        <p>
But the most beautiful creature out there? It's the butterfly! 
</p>
        <p>
        </p>
        <p>
          <img src="http://blog.wmdev.net/content/binary/052108_1004_Thebutterfl1.png" alt="" />
        </p>
        <p>
        </p>
        <p>
          <img src="http://blog.wmdev.net/content/binary/052108_1004_Thebutterfl2.png" alt="" />
        </p>
        <p>
        </p>
        <p>
          <img src="http://blog.wmdev.net/content/binary/052108_1004_Thebutterfl3.png" alt="" />
        </p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=bf5f1293-56c4-451d-8424-d069e1b7469a" />
      </div>
    </content>
  </entry>
  <entry>
    <title>A New Mobile N-tier Architecture (part 8)</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/05/16/ANewMobileNtierArchitecturePart8.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,366632de-0a7b-46b2-9cd4-ca4e1662b4f1.aspx</id>
    <published>2008-05-16T06:28:31-04:00</published>
    <updated>2008-05-28T23:40:45.31175-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <category term="Architecture" label="Architecture" scheme="http://blog.wmdev.net/CategoryView,category,Architecture.aspx" />
    <category term="Business" label="Business" scheme="http://blog.wmdev.net/CategoryView,category,Business.aspx" />
    <category term="Chris" label="Chris" scheme="http://blog.wmdev.net/CategoryView,category,Chris.aspx" />
    <category term="Compact Framework" label="Compact Framework" scheme="http://blog.wmdev.net/CategoryView,category,Compact%2BFramework.aspx" />
    <category term="Windows Mobile" label="Windows Mobile" scheme="http://blog.wmdev.net/CategoryView,category,Windows%2BMobile.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
We will continue the more practical part of this series by showing how the new mobile
architecture looks in code, and if you want some background, please see the previous
parts:
</p>
        <ul>
          <li>
            <a href="http://blog.wmdev.net/2008/03/28/ANewMobileNtierArchitecturePart1.aspx">Part
1</a> was a general introduction 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/04/ANewMobileNtierArchitecturePart2.aspx">Part
2</a> talked about the changes in the lower tiers (logic + data, LINQ2SQL) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/11/ANewMobileNtierArchitecturePart3.aspx">Part
3</a> discussed the changes in communication (WCF) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/18/ANewMobileNtierArchitecturePart4.aspx">Part
4</a> covered important stuff in the user interface (MVC) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/25/ANewMobileNtierArchitecturePart5.aspx">Part
5</a> summarized the theory and outlined the new architecture 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/05/02/ANewMobileNtierArchitecturePart6.aspx">Part
6</a> started the walkthrough of the architecture code by looking at the business
domain 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/05/09/ANewMobileNtierArchitecturePart7.aspx">Part
7</a> continued the code walkthrough with a look at the service (WCF)</li>
        </ul>
        <p>
The implemented architecture is published on <a href="http://www.codeplex.com/" target="_blank">CodePlex</a> in
a project called <a href="http://www.codeplex.com/wmarch/" target="_blank">Windows
Mobile Architecture Blueprint</a>, and this means that you can access the full source
code as well as discuss it, come with suggested improvements, etc. As I walk you through
the creation of the architecture, we suggest you keep the source code handy to check
out more details.
</p>
        <p>
We are now ready to consume the <a href="http://msdn.microsoft.com/en-us/library/ms735119.aspx" target="_blank">WCF</a> service
that we created in the previous post, and therefore we have added a new "Smart Device
Project" and selected to create a Device application targeting Windows Mobile 6 Standard
(a.k.a Smartphone) and the latest .NET Compact Framework (3.5).
</p>
        <p>
As the tools support is not yet in place in Visual Studio, to consume a WCF service,
you need to first download and install the <a href="http://www.microsoft.com/downloads/details.aspx?familyId=c8174c14-a27d-4148-bf01-86c2e0953eab" target="_blank">Power
Toys for .NET Compact Framework 3.5</a>. The tool that you are after is named NetCFSvcUtil.exe,
and you use it like this...
</p>
        <div style="font-size: 10pt; font-family: monospace; background-color: white">NetCFSvcUtil
/language:cs <a href="http://localhost:5610/Service.svc">http://localhost:5610/Service.svc</a></div>
        <p>
...and in the source code you can find a batch file (CreateServiceClient.bat) that
will run this command (note that you may have to change the path to the NetCFSvcUtil
utility depending on whether you're running on 32- or 64-bit). Note that the WCF service
must be running when you run this command, and the out of running this batch file
looks something like this...
</p>
        <p>
          <a href="http://blog.wmdev.net/content/binary/WindowsLiveWriter/ANewMobileNtierArchitecturepart8_959/netcfsvcutl_2.png">
            <img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="140" alt="netcfsvcutl" src="http://blog.wmdev.net/content/binary/WindowsLiveWriter/ANewMobileNtierArchitecturepart8_959/netcfsvcutl_thumb.png" width="640" border="0" />
          </a>
        </p>
        <p>
...with the result that two files are generated (Service.cs and CFClientBase.cs).
As there files are already part of the source code, they will simply be replaced and
the procedure with running the batch file is the next best thing to what you would
expect from integrated support in Visual Studio.
</p>
        <p>
Now, with these two files in place, we can start consuming the WCF service with code
like this...
</p>
        <div style="font-size: 10pt; font-family: monospace; background-color: white">
          <span style="color: #2b91af">ServiceClient</span>
          <span style="color: black">.EndpointAddress
= </span>
          <span style="color: blue">new</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">EndpointAddress</span>
          <span style="color: black">(</span>
          <span style="color: #a31515">"http://192.168.0.100:5610/Service.svc/basic"</span>
          <span style="color: black">);<br /></span>
          <span style="color: #2b91af">ServiceClient</span>
          <span style="color: black"> service
= </span>
          <span style="color: blue">new</span>
          <span style="color: black">
          </span>
          <span style="color: #2b91af">ServiceClient</span>
          <span style="color: black">();<br /></span>
          <span style="color: #2b91af">Category</span>
          <span style="color: black">[] categories
= service.GetCategories();</span>
        </div>
        <p>
...and the first thing we do is to set an endpoint of the service that the mobile
device can reach (in this case an IP address). Then the service proxy (ServiceClient)
is instantiated and used to retrieve the list of categories. Note that the business
entity (Category) that was declared back in the business domain (automatically generated
by <a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx" target="_blank">LINQ2SQL</a>,
and automatically serialized by WCF) is readily available on the mobile client (thanks
to the proxy we generated above).
</p>
        <p>
In future posts, we will cover more parts of the architecture blueprint implementation.
</p>
        <p>
In some projects, we have used a very simple and straightforward implementation by
our former fellow MVP, Alex Yakhnin (he's now employed by Microsoft), that he published
as a small blog series last fall (see <a href="http://blogs.msdn.com/priozersk/archive/2007/08/06/implementing-mvc-pattern-in-net-cf-applications-part-1.aspx" target="_blank">part
1</a> and <a href="http://blogs.msdn.com/priozersk/archive/2007/08/07/implementing-mvc-pattern-in-net-cf-applications-part-2.aspx" target="_blank">part
2</a>).
</p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=366632de-0a7b-46b2-9cd4-ca4e1662b4f1" />
      </div>
    </content>
  </entry>
  <entry>
    <title>A New Mobile N-tier Architecture (part 7)</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/05/09/ANewMobileNtierArchitecturePart7.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,25ba4d0c-f03d-4420-b64f-547c417b7ee4.aspx</id>
    <published>2008-05-09T06:27:52-04:00</published>
    <updated>2008-05-28T10:05:10.327375-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <category term="Architecture" label="Architecture" scheme="http://blog.wmdev.net/CategoryView,category,Architecture.aspx" />
    <category term="Business" label="Business" scheme="http://blog.wmdev.net/CategoryView,category,Business.aspx" />
    <category term="Chris" label="Chris" scheme="http://blog.wmdev.net/CategoryView,category,Chris.aspx" />
    <category term="Compact Framework" label="Compact Framework" scheme="http://blog.wmdev.net/CategoryView,category,Compact%2BFramework.aspx" />
    <category term="Windows Mobile" label="Windows Mobile" scheme="http://blog.wmdev.net/CategoryView,category,Windows%2BMobile.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
WeI will continue the more practical part of this series by showing how the new mobile
architecture looks in code, and if you want some background, please see the previous
parts:
</p>
        <ul>
          <li>
            <a href="http://blog.wmdev.net/2008/03/28/ANewMobileNtierArchitecturePart1.aspx">Part
1</a> was a general introduction 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/04/ANewMobileNtierArchitecturePart2.aspx">Part
2</a> talked about the changes in the lower tiers (logic + data, LINQ2SQL) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/11/ANewMobileNtierArchitecturePart3.aspx">Part
3</a> discussed the changes in communication (WCF) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/18/ANewMobileNtierArchitecturePart4.aspx">Part
4</a> covered important stuff in the user interface (MVC) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/25/ANewMobileNtierArchitecturePart5.aspx">Part
5</a> summarized the theory and outlined the new architecture 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/05/02/ANewMobileNtierArchitecturePart6.aspx">Part
6</a> started the walkthrough of the architecture code by looking at the business
domain</li>
        </ul>
        <p>
The implemented architecture is published on <a href="http://www.codeplex.com/" target="_blank">CodePlex</a> in
a project called <a href="http://www.codeplex.com/wmarch/" target="_blank">Windows
Mobile Architecture Blueprint</a>, and this means that you can access the full source
code as well as discuss it, come with suggested improvements, etc. As I walk you through
the creation of the architecture, we suggest you keep the source code handy to
check out more details.
</p>
        <p>
The next step in building the architecture is to create the service interface (i.e.
the service), and therefore we have added a new "WCF Service Application" project
called Blueprint.Facade to the solution that already included the business domain
project (Blueprint.Domain). Our first service will be publishing the very simple
functionality that the business domain provides (the ability to retrieve all categories
from the database). First, we have renamed the service interface to IService
and the service implementation to Service (removed the "1" at the end on both), and
here you need to make sure that all references are updated (four occurences in the
web.config file and don't forget the one in Service.svc). The implementation of the
service interface (IService.cs) can be done like this...
</p>
        <div style="FONT-SIZE: 10pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white">[<span style="COLOR: #2b91af">ServiceContract</span><span style="COLOR: black">]<br /></span><span style="COLOR: blue">public</span><span style="COLOR: black"></span><span style="COLOR: blue">interface</span><span style="COLOR: black"></span><span style="COLOR: #2b91af">IService<br /></span><span style="COLOR: black">{<br />
    [</span><span style="COLOR: #2b91af">OperationContract</span><span style="COLOR: black">]<br />
    </span><span style="COLOR: #2b91af">Category</span><span style="COLOR: black">[]
GetCategories();<br /></span><span style="COLOR: black">}</span></div>
        <p>
...and with a reference to the business domain project, the service implementation
(Service.svc.cs) can be implemented with this code...
</p>
        <div style="FONT-SIZE: 10pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white">
          <span style="COLOR: blue">public</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: blue">class</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: #2b91af">Service</span>
          <span style="COLOR: black"> : </span>
          <span style="COLOR: #2b91af">IService<br /></span>
          <span style="COLOR: black">{<br />
    </span>
          <span style="COLOR: blue">public</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: #2b91af">Category</span>
          <span style="COLOR: black">[]
GetCategories()<br />
    {<br />
        </span>
          <span style="COLOR: blue">using</span>
          <span style="COLOR: black">(</span>
          <span style="COLOR: #2b91af">NorthwindDataContext</span>
          <span style="COLOR: black"> dc
= </span>
          <span style="COLOR: blue">new</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: #2b91af">NorthwindDataContext</span>
          <span style="COLOR: black">())<br />
            </span>
          <span style="COLOR: blue">return</span>
          <span style="COLOR: black"> dc.GetCategories();<br />
    }<br /></span>
          <span style="COLOR: black">}</span>
        </div>
        <p>
...to complete the implementation of the service. When the project is built and run,
the WCF is ready to be consumed, and therefore it's a good idea to remember the URL
to the service as we will need it in the next post when we will look at how this service
can be consumed from a mobile client application.
</p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=25ba4d0c-f03d-4420-b64f-547c417b7ee4" />
      </div>
    </content>
  </entry>
  <entry>
    <title>.NET CF 3.5 Breaking Changes</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/05/07/NETCF35BreakingChanges.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,82088285-7a74-4b2c-b8ca-8abe07c683fa.aspx</id>
    <published>2008-05-07T03:27:28.18-04:00</published>
    <updated>2008-05-16T03:27:28.180625-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <category term="Compact Framework" label="Compact Framework" scheme="http://blog.wmdev.net/CategoryView,category,Compact%2BFramework.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I am migrating a .NET CF 2-application to .NET CF 3.5. We haven't come across any
breaking changes in our project. In fact, we've just seen benefits from the upgrade
(ie performance). However, if you are about to do the same thing, don't miss the article: <a href="http://msdn.microsoft.com/en-us/netframework/bb986636.aspx">.NET
Compact Framework 3.5 Run-Time Breaking Changes...</a></p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=82088285-7a74-4b2c-b8ca-8abe07c683fa" />
      </div>
    </content>
  </entry>
  <entry>
    <title>A New Mobile N-tier Architecture (part 6)</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/05/02/ANewMobileNtierArchitecturePart6.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,6dfd5d61-ff4d-431b-b236-01fd1cf75cd1.aspx</id>
    <published>2008-05-02T06:23:32-04:00</published>
    <updated>2008-05-28T10:08:51.093-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <category term="Architecture" label="Architecture" scheme="http://blog.wmdev.net/CategoryView,category,Architecture.aspx" />
    <category term="Business" label="Business" scheme="http://blog.wmdev.net/CategoryView,category,Business.aspx" />
    <category term="Chris" label="Chris" scheme="http://blog.wmdev.net/CategoryView,category,Chris.aspx" />
    <category term="Compact Framework" label="Compact Framework" scheme="http://blog.wmdev.net/CategoryView,category,Compact%2BFramework.aspx" />
    <category term="Windows Mobile" label="Windows Mobile" scheme="http://blog.wmdev.net/CategoryView,category,Windows%2BMobile.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
In this part, we will get more practical by showing how the first parts of this
new mobile architecture looks in code, and if you want some background, please see
the previous parts:
</p>
        <ul>
          <li>
            <a href="http://blog.wmdev.net/2008/03/28/ANewMobileNtierArchitecturePart1.aspx">Part
1</a> was a general introduction 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/04/ANewMobileNtierArchitecturePart2.aspx">Part
2</a> talked about the changes in the lower tiers (logic + data, LINQ2SQL) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/11/ANewMobileNtierArchitecturePart3.aspx">Part
3</a> discussed the changes in communication (WCF) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/18/ANewMobileNtierArchitecturePart4.aspx">Part
4</a> covered important stuff in the user interface (MVC) 
</li>
          <li>
            <a href="http://blog.wmdev.net/2008/04/25/ANewMobileNtierArchitecturePart5.aspx">Part
5</a> summarized the theory and outlined the new architecture</li>
        </ul>
        <p>
The implemented architecture is published on <a href="http://www.codeplex.com/" target="_blank">CodePlex</a> in
a project called <a href="http://www.codeplex.com/wmarch/" target="_blank">Windows
Mobile Architecture Blueprint</a>, and this means that you can access the full source
code as well as discuss it, come with suggested improvements, etc. As I walk you through
the creation of the architecture, we suggest you keep the source code handy to
check out more details.
</p>
        <p>
          <a href="http://blog.wmdev.net/content/binary/WindowsLiveWriter/ANewMobileNtierArchitectureLINQpart3_C7A0/nwdatacontext_4.png">
            <img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="166" alt="nwdatacontext" src="http://blog.wmdev.net/content/binary/WindowsLiveWriter/ANewMobileNtierArchitectureLINQpart3_C7A0/nwdatacontext_thumb_1.png" width="287" align="right" border="0" />
          </a> Ok,
let's start building the architecture from the ground up!  To make things really
simple (remember the <a href="http://en.wikipedia.org/wiki/KISS_principle" target="_blank">KISS
principle</a>), we have started with a plain class library called Blueprint.Domain
where we will keep my business domains. My first domain will be covering a small
part of the classic Northwind database. I started by creating a <a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx" target="_blank">LINQ2SQL</a> data
context called Northwind and dragged two of the Northwind tables into it (if you're
like me, and don't have the Northwind database installed, you can <a href="http://msdn.microsoft.com/en-us/library/ms165732.aspx" target="_blank">get
it here</a>) as you can see on the right (note that we have removed the Picture
field in the Category table to save bandwidth).
</p>
        <p>
When that is done, a neat trick that will come in very handy is to select Properties
on the design canvas of the data context and set Serialization Mode to Unidirectional.
By doing this simple task, the code generated for the data context will include the
necessary decorations (attributes) to make the data context ready to be published
by <a href="http://msdn.microsoft.com/en-us/library/ms735119.aspx" target="_blank">WCF</a>.
If we look at a stripped version of the generated code (in Northwind.designer.cs)... 
</p>
        <div style="FONT-SIZE: 10pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white">
          <span style="COLOR: blue">public</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: blue">partial</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: blue">class</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: #2b91af">NorthwindDataContext</span>
          <span style="COLOR: black"> :
System.Data.Linq.</span>
          <span style="COLOR: #2b91af">DataContext<br /></span>
          <span style="COLOR: black">{<br /></span>
          <span style="COLOR: black">    [</span>
          <span style="COLOR: #2b91af">DataContract</span>
          <span style="COLOR: black">()]<br /></span>
          <span style="COLOR: blue">    public</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: blue">partial</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: blue">class</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: #2b91af">Category</span>
        </div>
        <div style="FONT-SIZE: 10pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white">
          <span style="COLOR: #2b91af">
          </span>
          <span style="COLOR: black">   
{<br /></span>
          <span style="COLOR: black">        [</span>
          <span style="COLOR: #2b91af">DataMember</span>
          <span style="COLOR: black">(Order=1)]<br />
        </span>
          <span style="COLOR: blue">public</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: blue">int</span>
          <span style="COLOR: black"> CategoryID<br />
        {<br /></span>
        </div>
        <p>
...you will see that each class (entity) has a DataContract attribute, and each field
(attribute) has a DataMember attribute. These attributes will be use by WCF when the
entities are communicated.
</p>
        <p>
In the code above, please also note that the generated class for the data context
(NorthwindDataContext) is declared "partial" which perfectly matches our intention
of implementing the business logic in a parallel class. By creating such a class (Northwind.cs),
and putting in some simple code like this...
</p>
        <div style="FONT-SIZE: 10pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white">
          <span style="COLOR: blue">public</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: blue">partial</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: blue">class</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: #2b91af">NorthwindDataContext<br /></span>
          <span style="COLOR: black">{<br />
    </span>
          <span style="COLOR: blue">public</span>
          <span style="COLOR: black">
          </span>
          <span style="COLOR: #2b91af">Category</span>
          <span style="COLOR: black">[]
GetCategories()<br />
    {</span>
        </div>
        <div style="FONT-SIZE: 10pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white">
          <span style="COLOR: green">        <span style="COLOR: blue">return <span style="COLOR: black">Categories.ToArray();</span></span><br /></span>
          <span style="COLOR: black">    }<br />
}</span>
        </div>
        <p>
...we have implemented the first (however sparse) service into our first business
domain, and the functionality is that it returns the list of all categories. Note
that behind the scenes, LINQ comes into play, and to show a more obvious example,
we can do this instead...
</p>
        <div style="FONT-SIZE: 10pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white">
          <span style="COLOR: blue">var</span>
          <span style="COLOR: black"> q
= </span>
          <span style="COLOR: blue">from</span>
          <span style="COLOR: black"> c </span>
          <span style="COLOR: blue">in</span>
          <span style="COLOR: black"> Categories </span>
          <span style="COLOR: blue">select</span>
          <span style="COLOR: black"> c;</span>
        </div>
        <div style="FONT-SIZE: 10pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white">
          <span style="COLOR: blue">return</span>
          <span style="COLOR: black"> q.ToArray();</span>
        </div>
        <div style="FONT-SIZE: 10pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white">
          <span style="COLOR: black">
            <br />
 
</span>
        </div>
        <p>
...and this will create the same result as the code above. Worth mentioning already
is the fact that even if the Category entity holds a relation to all products in that
category, those child entities are not loaded by default. This is a good thing as
you probably don't want to load all products with all categories, but when you want
to load related entities, you can do this by explicitly call...
</p>
        <div style="FONT-SIZE: 10pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white">
          <span style="COLOR: blue">var</span>
          <span style="COLOR: black"> q
= </span>
          <span style="COLOR: blue">from</span>
          <span style="COLOR: black"> c </span>
          <span style="COLOR: blue">in</span>
          <span style="COLOR: black"> Categories </span>
          <span style="COLOR: blue">select</span>
          <span style="COLOR: black"> c;</span>
        </div>
        <div style="FONT-SIZE: 10pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white">
          <span style="COLOR: black">
          </span>
          <span style="COLOR: #2b91af">Category</span>
          <span style="COLOR: black">[]
categories = q.ToArray();</span>
        </div>
        <div style="FONT-SIZE: 10pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white">
          <span style="COLOR: black">categories[0].Products.Load();</span>
          <span style="COLOR: black">
            <br />
          </span>
        </div>
        <p>
...to load all the products for the first category. There are some other options for
controlling how related entities are loaded, but it's out-of-scope for this blog post.
In future posts in this series, we will cover more parts of the architecture
blueprint implementation.
</p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=6dfd5d61-ff4d-431b-b236-01fd1cf75cd1" />
      </div>
    </content>
  </entry>
  <entry>
    <title>A New Mobile N-tier Architecture (part 5)</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/04/25/ANewMobileNtierArchitecturePart5.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,bae13e36-ca75-42a5-b6b7-cf7412b13594.aspx</id>
    <published>2008-04-25T06:22:54-04:00</published>
    <updated>2008-05-28T10:09:29.56175-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <category term="Architecture" label="Architecture" scheme="http://blog.wmdev.net/CategoryView,category,Architecture.aspx" />
    <category term="Business" label="Business" scheme="http://blog.wmdev.net/CategoryView,category,Business.aspx" />
    <category term="Chris" label="Chris" scheme="http://blog.wmdev.net/CategoryView,category,Chris.aspx" />
    <category term="Compact Framework" label="Compact Framework" scheme="http://blog.wmdev.net/CategoryView,category,Compact%2BFramework.aspx" />
    <category term="Windows Mobile" label="Windows Mobile" scheme="http://blog.wmdev.net/CategoryView,category,Windows%2BMobile.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
In the previous parts of this series, we have discussed the changes that affect
the architecture design. It's now time to conclude what this all leads up to architecture-wise,
and we propose that the architecture should look something like this:
</p>
        <p>
          <a href="http://blog.wmdev.net/content/binary/WindowsLiveWriter/ANewMobileNtierArchitecturepart5_13957/newarch_2.png">
            <img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="348" alt="newarch" src="http://blog.wmdev.net/content/binary/WindowsLiveWriter/ANewMobileNtierArchitecturepart5_13957/newarch_thumb.png" width="258" align="left" border="0" />
          </a> Most
of the fundamental parts (three tiers, common services, etc), and even many of the
more specific (service interfaces/agents, data access, business entities, etc) are
exactly the same as in the <a href="http://msdn.microsoft.com/en-us/library/ms954595.aspx" target="_blank">Application
Architecture for .NET</a> that I've mentioned before in this series of blog posts.
</p>
        <p>
Note that a significant change is the merge of the lower part of the middle (business
services) tier and the bottom (data services) tier. As we've outlined before, this
is where the business logic and its data comes together in a nice mix called the business
domains. With technologies like <a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx" target="_blank">LINQ
to SQL</a> and <a href="http://msdn.microsoft.com/en-us/library/ms735119.aspx" target="_blank">WCF</a>,
most (if not all) of the data services tier are actually created using code generation.
This means that any changes made to the different sources (data sources and services)
can be captured by regenerating the code. The tools support is actually prepared for
this kind of evolution in the integration between systems, and a simple "Update Service
Reference" menu selection is all that is needed.
</p>
        <p>
Another similar change is the clear separation between the service interfaces and
the business domains. Where the business domains have a clear responsibility to handle
the logic and data for a certain business domain, the service interfaces (designed
according to the <a href="http://en.wikipedia.org/wiki/Facade_pattern" target="_blank">facade
pattern</a>) has a different set of responsibilities. The primary distinction of a
service interface is that it probably fulfills a specific part of the system's functionality
(use case). Also, as they are the "first line of defense", they should handle things
like basic security (authentication, authorization, encryption, etc) as well as secure
coding techniques (parameter checking, prevent things like SQL/code injection, etc),
compression, transactions, logging, etc. A consequence of the separation with the
business domains is that the service can be placed in a separate assembly. This is
a good thing because a service interface probably uses a number of business domains
that may (or may not) exist in numerous assemblies.
</p>
        <p>
Finally, the user interface parts have been renamed to align with the use of the <a href="http://en.wikipedia.org/wiki/Model-view-controller" target="_blank">MVC</a> pattern,
and as already mentioned in previous posts, this will allow for better testing and
the use of the same user interface logic for different clients (thin Web interfaces
built with ASP.NET, rich interfaces built with WinForms, WPF or Silverlight, and of
course mobile clients built with .NET CF and soon Silverlight, etc).
</p>
        <p>
In upcoming posts, we will continue with more of my thoughts on the changes in
mobile architecture, and of course also some code samples to show the theory in practice.
Stay tuned!
</p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=bae13e36-ca75-42a5-b6b7-cf7412b13594" />
      </div>
    </content>
  </entry>
  <entry>
    <title>How Do I...</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/04/21/HowDoI.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,6369fdec-20e1-49fc-9a0b-243bb1f296f8.aspx</id>
    <published>2008-04-21T03:23:18.743-04:00</published>
    <updated>2008-05-16T03:23:18.743125-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <category term="Compact Framework" label="Compact Framework" scheme="http://blog.wmdev.net/CategoryView,category,Compact%2BFramework.aspx" />
    <category term="SQL Server CE" label="SQL Server CE" scheme="http://blog.wmdev.net/CategoryView,category,SQL%2BServer%2BCE.aspx" />
    <category term="Tools" label="Tools" scheme="http://blog.wmdev.net/CategoryView,category,Tools.aspx" />
    <category term="Windows Mobile" label="Windows Mobile" scheme="http://blog.wmdev.net/CategoryView,category,Windows%2BMobile.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
MSDN has a number of excellent "How Do I"-videos geared towards Windows Mobile-development. <a href="http://msdn.microsoft.com/en-us/netframework/bb495180.aspx">Don't
miss it...</a></p>
        <p>
I've found the following to be very useful:
</p>
        <p>
          <a id="ctl00_mainContentContainer_ctl27" onclick="javascript:Track('ctl00_mainContentContainer_ctl00|ctl00_mainContentContainer_ctl27',this);" href="http://msdn.microsoft.com/en-us/netframework/cc296429.aspx">
            <font color="#0033cc">How
Do I: Test Unit Tests for Devices?</font>
          </a>
          <br />
          <a id="ctl00_mainContentContainer_ctl23" onclick="javascript:Track('ctl00_mainContentContainer_ctl00|ctl00_mainContentContainer_ctl23',this);" href="http://msdn.microsoft.com/en-us/netframework/cc307206.aspx">
            <font color="#0033cc">How
Do I: Update User Interface Controls in Multithreaded Applications?</font>
          </a>
          <br />
          <a id="ctl00_mainContentContainer_ctl19" onclick="javascript:Track('ctl00_mainContentContainer_ctl00|ctl00_mainContentContainer_ctl19',this);" href="http://msdn.microsoft.com/en-us/netframework/cc315060.aspx">
            <font color="#0033cc">How
Do I: Efficiently Query a SQL Server Compact Database Using LINQ?</font>
          </a>
        </p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=6369fdec-20e1-49fc-9a0b-243bb1f296f8" />
      </div>
    </content>
  </entry>
  <entry>
    <title>A New Mobile N-tier Architecture (part 4)</title>
    <link rel="alternate" type="text/html" href="http://blog.wmdev.net/2008/04/18/ANewMobileNtierArchitecturePart4.aspx" />
    <id>http://blog.wmdev.net/PermaLink,guid,7b8ab303-2bd2-449e-a7bb-feea4af07c1a.aspx</id>
    <published>2008-04-18T06:21:55-04:00</published>
    <updated>2008-05-28T10:10:23.2805-04:00</updated>
    <category term="Andy" label="Andy" scheme="http://blog.wmdev.net/CategoryView,category,Andy.aspx" />
    <category term="Architecture" label="Architecture" scheme="http://blog.wmdev.net/CategoryView,category,Architecture.aspx" />
    <category term="Business" label="Business" scheme="http://blog.wmdev.net/CategoryView,category,Business.aspx" />
    <category term="Chris" label="Chris" scheme="http://blog.wmdev.net/CategoryView,category,Chris.aspx" />
    <category term="Compact Framework" label="Compact Framework" scheme="http://blog.wmdev.net/CategoryView,category,Compact%2BFramework.aspx" />
    <category term="Windows Mobile" label="Windows Mobile" scheme="http://blog.wmdev.net/CategoryView,category,Windows%2BMobile.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
This time we will look a little closer at an important change on the user interface
side of the architecture. We're talking about applying the <a href="http://en.wikipedia.org/wiki/Model-view-controller" target="_blank">MVC</a> pattern
(or rather its variation, the <a href="http://en.wikipedia.org/wiki/Model_View_Presenter" target="_blank">MVP</a> pattern),
and even if this change is far from recent (both mentioned patterns have been around
for quite awhile), the importance of applying this pattern has increased. The reason
is an increased focus on automatic testing, <a href="http://en.wikipedia.org/wiki/Test_driven_development" target="_blank">TDD</a>,
and <a href="http://en.wikipedia.org/wiki/Continuous_integration" target="_blank">continous
integration</a>. By applying the MVC pattern, the bulk of the logic of the user interface
(located in a "controller"), can be tested independent of the actual user interface.
This, and the more traditional benefits, that you can apply different "views" (user
interfaces or more general, channels) to the same user interface logic, makes the
MVC pattern a common part of any modern software architecture.
</p>
        <p>
If you do some browsing on the Web, you quickly find that there are many implementation
of the MVC pattern, but there are not that many specific to Windows Mobile developers
(although most .NET implementations should migrate without much hazzle). One great
initiative was the <a href="http://msdn.microsoft.com/en-us/library/aa480471.aspx" target="_blank">MCSF</a> by
Microsoft's patterns &amp; practices team, which included a solid implementation of
the MVC pattern (among many other) that was migrated from various application blocks
for the full .NET Framework. However, the MCSF was so solid that it took a great deal
of time to learn before you could be productive. Also, the MCSF is now a bit outdated,
and judging from the lack of news or updates about it, our hopes are not up.
</p>
        <p>
The community (and us too) wanted something simpler, and in some projects, we have
used a very simple and straightforward implementation by our former fellow MVP, Alex
Yakhnin (he's now employed by Microsoft), that he published as a small blog series
last fall (see <a href="http://blogs.msdn.com/priozersk/archive/2007/08/06/implementing-mvc-pattern-in-net-cf-applications-part-1.aspx" target="_blank">part
1</a> and <a href="http://blogs.msdn.com/priozersk/archive/2007/08/07/implementing-mvc-pattern-in-net-cf-applications-part-2.aspx" target="_blank">part
2</a>). In those blog posts Alex also showed a simple solution to a very common problem
when building great <a href="http://www.microsoft.com/design/" target="_blank">UX</a> for
Windows Mobile, and that is to handle the caching of forms. Loading a form is an expensive
task in terms of performance, and therefore it's necessary to cache the forms in memory.
</p>
        <p>
In upcoming posts, we will continue with more of my thoughts on the changes in
mobile architecture, and of course also some code samples to show the theory in practice.
</p>
        <img width="0" height="0" src="http://blog.wmdev.net/aggbug.ashx?id=7b8ab303-2bd2-449e-a7bb-feea4af07c1a" />
      </div>
    </content>
  </entry>
</feed>