# Monday, February 20, 2012

In my push to get our fundamental libraries up and working on Mono for Android we've added support for OpenNETCF Extensions and OpenNETCF IoC.  What that means is that now you can have a common code for a lot of application infrastructure that works on the Compact Framework, the desktop, Windows Phone, MonoTouch for iOS and Mono for Android.  So you can now create a single, common code base for your applications that includes data access, event aggregation, dependency injection and inversion of control.

Get the latest code over on Codeplex.

Monday, February 20, 2012 12:36:44 PM (Central Standard Time, UTC-06:00)  #     | 
# Wednesday, November 16, 2011

REST web services are pretty straightforward and really, really common (you used one to read this blog page).  As software gets implemented as services, it's getting more and more common for us as developers to have to make REST calls programmatically.  Lately I've been implementing a lot of services using Padarn on both the device and the PC and then implementing client libraries to access those services.  In doing so, it only made sense to create some infrastructure to make my life a little easier, and so the RestConnector (and DigestRestConnector) was born.

For a simple GET, such as to get the response for this page, the code is trivial:

 

var connector = new RestConnector("blog.opennetcf.com");
var response = connector.Get("/ctacke");

Other verbs like POST and PUT are nearly as simple.

var response = connector.Post("/upload", myData);

For services that require authentication, there's the DigestRestConnector that behaves the same, except the ctor takes in a UID/PWD pair as well. The classes support the four common verbs I use: GET, PUT, POST and DELETE. Of course since it's open-source, feel free to extend them as you wish.


The OpenNETCF Extensions library is a collection of extension methods and helper classes that I find useful in a lot of different projects. It's compatible with the Compact Framework, Tirethe full framework and Windows Phone.

Wednesday, November 16, 2011 9:27:40 AM (Central Standard Time, UTC-06:00)  #     | 
# Friday, November 04, 2011

Marshaling UI access to the proper thread is a very common task in app development, yet it still tends to be a pain in the ass.  You have to check if InvokeRequired is true (well you probably don’t *have* to, but not doing it feels dirty to me) and even using an anonymous delegate tends to be verbose.  And then there are also the simple bugs that are not always easy to spot.

So, like any good developer, I stole someone else’s idea and put it into the OpenNETCF Extensions.  Now, instead of doing this:

void MyMethod()
{
    if (this.InvokeRequired)
    {
        this.Invoke(new EventHandler(delegate
            {
                MyMethod();
            }));
        return;
    }

    // do stuff with the UI
}

You do this:

void MyMethod()
{
    Invoker.InvokeIfRequired(i =>
    {
        // do stuff with the UI
    });
}

Less code.  Less potential for error.  More readable.  What’s not to like?


The OpenNETCF Extensions library is a collection of extension methods and helper classes that I find useful in a lot of different projects. It's compatible with the Compact Framework, Tirethe full framework and Windows Phone.

Friday, November 04, 2011 12:10:04 PM (Central Standard Time, UTC-06:00)  #     |