Project Description

Rialternative is lightweight framework to industrialize developments with Silverlight and WCF RIA Services.

It takes advantage of the great extensibility of WCF RIA Services to help developpers in Silverlight/WCF RIA Services solution design.


Basic approach

Rialternative allows data access layer abstraction by providing a Repository pattern implementation adapted to WCF Ria services. You can take advantage of it by inheriting of RepositoryDomainService class when you are developping your domain service. This base class contains a property of type IRepository which define C.R.U.D methods regardless of data access technology. Besides, Rialternative embeds two IRepository implementations, one for EntityFramework and one for unit testing.

Finally, to define the object context of your domain service the repository will use,  you can use the EntityDomainServiceDescriptionProvider.

Example :

public class NorthwindService : RepositoryDomainService
     public IQueryable<Categories> GetCategories()
         return this.Repository.GetQuery<Categories>();
     } }


Define standard C.R.U.D operations using AOP

Rialternative provides the EntityDomain C# attribute which allow to define easily the standard C.R.U.D operations that the domain service provides for an entity.

You can also define within this attribute the requested authorizations for a specific operation.

Example :

[EntityDomain(typeof(Customers), EntityDomainOperations.All, 
DeleteRequiresRole = new string[] { "CustomerManager", "Admin" })] [EntityDomain(typeof(Products), EntityDomainOperations.Query | EntityDomainOperations.Update,
RequiresAuthentication = EntityDomainOperations.Update)] [EntityDomainServiceDescriptionProvider(typeof(NorthwindEntities))] public class NorthwindService : RepositoryDomainService { }

Note : If you defined an operation using both the rialternative and the standard way, rialternative will retain the standard way.


Generation of operations authorizations on client side

Rialternative is able to introspect all your domain services to generate on the client proxy some properties which determinate the required authorizations to invoke an operation. You can use then these properties in the business logic of your application. The big advantage is if you want to change some authorizations of your domain service, Rialternative will update the client proxy at compilation time with the new rights and you do not have to change your business logic !

Example :

The following domain service settings….

[EntityDomain(typeof(Categories), EntityDomainOperations.Query | EntityDomainOperations.Update, 
UpdateRequiresRole = new string[] { "Admin", "CategoryManager" })] [EntityDomainServiceDescriptionProvider(typeof(NorthwindEntities))] public class NorthwindService : RepositoryDomainService { }

…will generate the following properties in the client proxy :

public bool CanGetCategories
      return System.ServiceModel.DomainServices.Client.ApplicationServices.
WebContextBase.Current.Authentication.User.Identity.IsAuthenticated; } }
public bool CanUpdateCategories { get { return System.ServiceModel.DomainServices.Client.ApplicationServices.
.Current.Authentication.User.IsInRole("Admin") ||
.Current.Authentication.User.IsInRole("CategoryManager"); } }


Configure a Domain Service to use Rialternative

To configure a Domain Service for Rialternative, the best way is to use the Application_Start handler of the Global.asax file of your web application. Rialternative need a dependency injection container to be able to inject the dedicated repository on demand but we did not want a strong relationship between Rialternative and a specific dependency injection container like Unity Application Block. In this way, Rialternative embed the IDIContainer interface that allow developpers to create their own implementation regarding the container they use in their application (Unity,, NInject, Func, etc…). To specify to Rialternative the implementation of IDIContainer you want to use to resolve your domain services, use the SetupContainer method of the Bootstrapper class. Then for each domain service you want to configure for Rialternative, use the ConfigureService method.

Example :

public class Global : System.Web.HttpApplication
     protected void Application_Start(object sender, EventArgs e)
         Bootstrapper.ConfigureService<NorthwindService, EntityFrameworkRepository<NorthwindEntities>>();
     } }

See the documentation section to have an example of IDIContainer implementation (just Unity for now).

Last edited Mar 13, 2011 at 6:52 PM by arnaudauroux, version 15