Here’s the first deploy of Structura, this project is related to our User Group DotNetMarche and will be part of a set of application frameworks and open source solutions we develop as community projects. Structura will be in our mind an application framework for building modular and pluggable line of business application in both Silverlight and WPF.

It will also contain a series of guidelines that will help structuring the project in a way that the portability between Silverlight and WPF will be maximized, reducing the amount of code you have to ‘rewrite’ hopefully only to the Xaml that describes the user interface.

The framework will make heavy use of patterns like MVP and MVVM for building the user interfaces, with a set of helper classes to structure the model, the views and the controllers. The model base class can be used also for your business entities and DTOs, cause it already implement all the interfaces to be effective when in binding with controls (using the dispatcher object all the PropertyChanged events will be called on the UI thread, so you don’t have to worry for access violations exceptions).

The modularity and pluggability is implemented using IoC containers (shielded behind an interface, so they can be changed), actually we use Unity for Silverlight and Castle Windsor for WPF. If you want you can write a custom bootstrap for the application that is able to register the types in the IoC containers using their native syntax, or you can follow my approach and use a custom syntax and programmatically register the types (this obviously set some limits in the features of the IoC containers you can use...but remember we aim for portability so keeping things simple is not an error).

All the Data Access logic is hidden behind WCF web services (you have to follow this way, cause Silverlight can’t realize a direct connection to a database or to any sort of data source). The DAL classes are implemented using NHibernate as ORM tool and follows a simple repository pattern. This is actually the ‘weakest ring of the chain’ for this sample cause I used a very basic implementation that we are already changing and improving in our other Open Source projects. You can use the ‘DataAccessLayer.UnitTest’ to generate the database used by the sample application, just change the connection string on the ‘DataService’ and ‘TestApp.DataAccessLayer.UnitTest’ projects, execute the first test and you are ready to go.

The framework also contains a series of utilities and controls specifically developed for Silverlight (like a Window emulator a Menu control, a file uploading feature, etc...).

The Test Application implemented is the very basis of an invoice system (it consists of 3 test modules, to show you the use of IoC as a plug-in engine, and 4 forms for inserting and managing clients and invoices). The project have a double user interface: Silverlight (TestApp.Silverlight.AppManagerWeb) and WPF (TestApp.AppManager).

InvoiceManagerSL InvoiceManagerWPF You do not need to use IIS to run this sample cause it works nicely using Cassini.

Attached to this article you’ll find the slides I made to present the project (and how it was planned from scratch) and an archive containing the solution (its weight should be around 5mb).

Attachments: This project will also appear in our community website:

By the way, excuse the very bad English I can use in the code comments (some of them may also be in Italian too :D), they will be fixed as the project go on. See you next time.

Related Content