Caliburn Micro on WinRT

Posted Thursday, August 2, 2012 by

Over the past week at Marker Metro I’ve had the chance to spend some time porting Caliburn Micro to WinRT! So I’m very proud to announce the release of our first experimental version.

There’s still some bugs to work out and test but I’ve managed to integrate some awesome extensions into Windows 8 such as implementing the Share charm simply by having your view model implementing the interface ISupportSharing as well as support for the Settings charm.

There’s still lots of work, and I’m proud that the core changes are already incorporated in the main project but I’d also suggest checking out our fork that includes the Windows 8 extensions and samples on how they work.

Windows 8 Hackathon

Posted Monday, April 2, 2012 by

A week ago I had the opportunity to attend a hackathon run out of the Auckland Microsoft office. The idea was to spend the weekend building a Windows 8 Metro application either as a one off experiment or for the longer term goal of having something ready for the launch of Windows 8. When developing with new platforms such as Metro and WinRT searches on Bing or Google won't help you so having some Microsoft experts and a lot of other developers around really helps smooth the rough edges you'll invariably encounter. It also provided the chance to sit down and use Windows 8 in anger, I think it's only after this sort of use that you can really judge a new operating system.

In terms of development I chose to keep working with C# and Xaml and found that almost all my skills from Windows Phone transferred across which was incredibly gratifying. There were obviously some new API's to learn around Tiles, the Charms and the new async / await syntax (which is awesome BTW), but this was expected and the API's I worked with held little surprises. I'll be sharing bits and pieces of what I learnt through the blog over the next few weeks. I found the new Visual Studio very good, although I missed Resharper and found myself mashing a lot of useless key combinations. This missing of old favorites was probably more keenly felt in that libraries and packages I'm used to developing with such as Caliburn Micro don't yet have ports to WinRT. I'm hoping these libraries will eventually make their way over.

After a weekend of solid use I'm feeling a lot more comfortable with Windows 8, initially I was having reservations about the Metro / Desktop split but now it's not jarring or distracting and I feel is fine. I do think there will need to be some sort of introduction tutorial for new users as I don't think a lot of the gestures / key combinations aren't intuitive. Even though this is a Consumer Preview / Beta not having more of an introductory experience is a misstep that may have put a lot of people off.

In the end the weekend was a great experience meeting some really talented individuals building some fantastic applications. I was also honored to have my app "Hubble" a GitHub issue management client voted by the other attendees as one of the top three apps winning me a new Nokia Lumia 800! I plan to continue development of the app and will put more details up as I go. A big thanks to all the people organizing the event, it was a great weekend.

Hubble

Visual Studio Styles

Posted Tuesday, November 2, 2010 by

I've had quite a few emails lately about the code sample colouring used on the website and where people can get it. I use a plugin named "Copy Source as Html" for the code samples on the blog so in a very cool way it simply uses my Visual Studio settings.

The style is named Son of Obsidian and it can be downloaded from the really neat Studio Styles website.

The blog has been pretty quiet lately as I've been working on two Windows Phone 7 applications, the first for general release on the marketplace and the second for a local competition, so fingers crossed in win.

Entity Framework Repositories

Posted Thursday, June 10, 2010 by

A long time ago I wrote a few posts about using "Domain Driven Design"-esque repositories using Linq to SQL ("Domain Driven Design Repositories in Linq to SQL"). I still use that general pattern with a few tweaks with extra layer of a "Unit of Work" to manage context lifetimes. I'm using this rebuild as a chance to play with Entity Framework 4 and so need to implement the appropriate interfaces all over again. The only major functionality change will be bringing in support for Entity Frameworks "Include".

I'm not going to go over the full pattern here, just the new parts for Entity Framework, the IRepository interface has changed that GetAll returns an interface IQuery which is pretty much the IQueryable interface with the Include method.

The implementations for IQuery and IRepository are as follows.

public class EntityRepository<T> : IRepository<T> where T : class

{

    private readonly ObjectSet<T> objectSet;

 

    public EntityRepository(ObjectSet<T> objectSet)

    {

        this.objectSet = objectSet;

    }

 

    public IQuery<T> GetAll()

    {

        return new EntityQuery<T>(objectSet);

    }

 

    public void Save(T entity)

    {

        if (entity == null)

            throw new ArgumentNullException("entity");

 

        objectSet.AddObject(entity);

    }

 

    public void Update(T entity)

    {

        if (entity == null)

            throw new ArgumentNullException("entity");

 

        objectSet.Attach(entity);

    }

 

    public void Delete(T entity)

    {

        if (entity == null)

            throw new ArgumentNullException("entity");

 

        objectSet.DeleteObject(entity);

    }

}

public class EntityQuery<T> : IQuery<T>

{

    private readonly ObjectQuery<T> query;

 

    public EntityQuery(ObjectQuery<T> query)

    {

        this.query = query;

    }

 

    public IQuery<T> Include(string path)

    {

        return new EntityQuery<T>(query.Include(path));

    }

 

    IEnumerator<T> IEnumerable<T>.GetEnumerator()

    {

        return ((IEnumerable<T>)query).GetEnumerator();

    }

 

    IEnumerator IEnumerable.GetEnumerator()

    {

        return ((IEnumerable)query).GetEnumerator();

    }

 

    Expression IQueryable.Expression

    {

        get

        {

            return ((IQueryable)query).Expression;

        }

    }

 

    Type IQueryable.ElementType

    {

        get

        {

            return ((IQueryable)query).ElementType;

        }

    }

 

    IQueryProvider IQueryable.Provider

    {

        get

        {

            return ((IQueryable)query).Provider;

        }

    }

}

The actual Repository that gets used by the domain layer simply delegates all it's work back to a internal repository based off the current unit of work. This is important section because it decouples the domain repository from repository doing the actual work and allows me to change the underlying data source if necessary.

public class Repository<T> : IRepository<T> where T : class

{

    private static IRepository<T> Current

    {

        get

        {

            return UnitOfWork.Current.CreateRepository<T>();

        }

    }

 

    public virtual IQuery<T> GetAll()

    {

        return Current.GetAll();

    }

 

    public virtual void Save(T entity)

    {

        if (entity == null)

            throw new ArgumentNullException("entity");

 

        Current.Save(entity);

    }

 

    public virtual void Update(T entity)

    {

        if (entity == null)

            throw new ArgumentNullException("entity");

 

        Current.Update(entity);

    }

 

    public virtual void Delete(T entity)

    {

        if (entity == null)

            throw new ArgumentNullException("entity");

 

        Current.Delete(entity);

    }

}

I'll get into the Unit of Work stuff in my next post.

Page 1 of 212>

Professional Windows App Development