Using CSLA .NET for Silverlight to Build Line-of-Business Applications
CSLA .NET for Silverlight is a version of CSLA .NET framework specifically written to support development of Silverlight applications. Microsoft's Silverlight is a cross-browser plug-in that uses XAML and a subset of .NET to enable rich client applications across platforms.
CSLA, written by Rockford Lhotka, has been around for over a decade. The purpose of CSLA is to provide developers with a solid framework to house business logic for applications. Microsoft .NET developers have adapted CSLA to new technologies as they emerge, and many developers use CSLA .NET heavily to construct robust, scalable .NET-based solutions supported on all Microsoft UI platforms, Windows, and the Web. CSLA .NET for Silverlight enables developers to create an object-oriented business layer that abstracts and encapsulates your business logic and data. CSLA .NET for Silverlight simplifies and standardizes the implementation of business logic, validation, and authorization within your objects. The goal is to provide an easy and consistent coding pattern by which you can encapsulate all your business logic within your object-oriented business layer. The result is a business layer that supports development of rich, interactive Silverlight applications.
CSLA .NET for Silverlight is a version of CSLA .NET framework specifically written to support development of Silverlight applications
CSLA .NET for Silverlight’s key features remain the same: full support for Silverlight data binding, N-level Undo, authorization / authentication features, validation rules, abstract data persistence, mobile objects that span physical boundaries to perform business functions, and multi-tier deployment model support.
You can use CSLA .NET for Silverlight to develop scalable line-of-business applications using Silverlight. Since Silverlight applications run in a Web browser, it is apparent that an application server component must be present in a Silverlight application. CSLA .NET for Silverlight has two primary ways to interact with an application server.
The most common one will probably be the CSLA .NET for Silverlight remote data portal. In this scenario, the Silverlight client calls the data portal for all CRUD operations, and the data portal will invoke CSLA .NET components on the server. In this case, CSLA .NET for Silverlight-based applications will still use CSLA .NET functionality to implement the data portal and business objects will move between the client and server just like they do in .NET.
The other primary scenario uses the CSLA .NET for Silverlight local data portal. In this case the Silverlight client calls the data portal, but the data access code runs on the Silverlight client. These data access methods will typically make calls to an external service (for example a WCF service, ADO.NET Data Services, or traditional Web service) to get or update data.
CSLA .NET for Silverlight supports the following standard CSLA business object stereotypes:
- Editable root.
- Editable child.
- Readonly root.
- Readonly child.
- Editable root list.
- Editable child list.
- Readonly root list.
- Readonly child list.
- Name/value list.
- Dynamic root list.
- Dynamic root.
You will need a number of projects for a CSLA .NET for Silverlight solution. You can observe the solution structure in Figure 1. The first project is a .NET class library (Rolodex.Business.Server) that will also share business object class files with the Silverlight class library (Rolodex.Business.Client). You will also need an actual Silverlight application project (Rolodex) that compiles into the Silverlight XAP file/executable assembly. Finally, you need a Web project (Web) to host the Silverlight application. This project can, at the same time, host the CSLA .NET data portal application server components. Alternatively you can create a separate project to host the data portal (WcfHostWeb).
Figure 1: Solution structure for CSLA .NET for Silverlight-based application.
By: Rockford Lhotka
Rockford Lhotka is the author of several books, including the Expert VB and C# 2005 Business Objects books and related CSLA .NET framework. He is a Microsoft Regional Director, MVP, and INETA speaker. Rockford is the Principal Technology Evangelist for Magenic (www.magenic.com), a Microsoft Gold Certified Partner.
By: Justin Chase
Justin Chase is a Software Professional working with Magenic since 2005. He is the lead developer on the open source project NBusiness.
CSLA.NET for Silverlight offers developers tools to create .NET applications designed to run on the Silverlight platform, while taking advantage of a multitude of CSLA features, including data binding, validation and business rules, authorization, abstract data persistence, consistent coding, and business logic encapsulation.